Friday, 11 December 2015

write a program that input 4 numbers and tells maximum number using if statement in c++

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{ int a,b,c,d;
cout<<"Enter 4 numbers to find maximum number"<<endl;
cin>>a>>b>>c>>d;
if(a>b)
{ if(a>c)
{cout<<a<<" is maximum"<<endl;}
else if(a>d)
{cout<<a<<" is maximum"<<endl;}
else
{cout<<d<<" is maximum"<<endl;}
}
else if(b>c)
{ if(b>d)

{cout<<b<<" is maximum"<<endl;}
else
{cout<<d<<" is maximum"<<endl;}

}
else if(c>d)
cout<<c<<" is maximum"<<endl;
else
cout<<d<<" is maximum"<<endl;
getch();
}

No comments:

Post a Comment