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