find greatest among 4 numbers

#include
#include
using namespace std;
int max_of_four(int a,int b, int c,int d)
{
if(a>=b && a>=c && a>=d)
{
return a;
}
else
if(b>=c && b>=d && b>=a)
{
return b;
}
else
if(c>=d && c>=a &&c>=b)
{
return c;
}
else
{
return d;

}
}
int main()
{
int a,b,c,d;
cout<<"\nEnter the Four Value:";
cin>>a>>b>>c>>d;
int ans=max_of_four(a,b,c,d);
cout<<"\nThe max of value is:"<<"\t"<<ans;
}

0 comments:

Post a Comment