Wednesday 1 June 2016

Write a Program that uses a function EQ() to find whether four integers a, b, c and d satisfy the equation a^3+b^3+c^3=d^3 or not. The function returns 0 if the equation is satisfied and return -1 otherwise.

#include<iostream.h>
#include<conio.h>
#include<math.h>
int EQ(int a, int b, int c, int d);
void main()
{
        clrscr();
        int n1, n2, n3, n4, r;
        cout<<"Enter four integers: ";
        cin>.n1>>n2>>n3>>n4;
        r = EQ(n1,n2,n3,n4);
        if(r == 0)
                cout<<"The values of a, b, c and d satisfies the equation";
        if(r== -1)
                cout<<"The values a, b, c and d does not satisfied the equation";
        getch();
}
int EQ(int a, int b, int c, int d)
{
        if(pow(a,3)+pow(b,3)+pow(c,3) == pow(d,3))
                return 0;
        else
                return -1;
}

Share:

0 comments:

Post a Comment

Popular Posts

Recent Posts

Unordered List

Text Widget

Pages

About Me

My photo
A group of two, with a little hope of helping beginners to learn how to code :)
Powered by Blogger.

Comments

Facebook

Ad Home

Follow Us

Random Posts

Sponsor

Recent Posts

Header Ads

Popular Posts

Copyright © Functions in C++ | Powered by Blogger

Design by ThemePacific | Blogger Theme by NewBloggerThemes.com | Distributed By Blogger Templates20