"The best way to cheer yourself up is to try to cheer somebody else up." Mark Twain

Sunday, February 21, 2010

Do the following :


Write a complete C++ program that invokes a function satis() to find whether four integers a,b,c,d sent to satis() satisfy the equation a3+b3+c3 = d3 or not. The function satis() returns 0 if the above equation is satisfied with the given four numbers otherwise it returns -1



#include<iostream.h>
#include<conio.h>
int satis(int a, int b, int c, int d)
{
if( a*a*a + b*b*b + c*c*c == d*d*d)
return 0;
else
return -1;
}
void main()
{
cout<< "\n Enter 4 integers : ";
int x, y, z, w;
int s = satis( x,y,z,w);
if(s == 0)
cout<< "\n The equation is satisfied";
else
cout<< "\n The equation is NOT satisfied";
getch();
}

No comments:

Post a Comment

C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off.
Now Playing: Ballade Pour Adeline

About Me

My photo
I m an IT lecturer of a college. I love social-work. I want to do something beneficial for society before dying , that can promote our society, to some extent.