Friday, 2 November 2012

Get Maximum Number


//This Program will get 3 number and will print Maximum Number....
#include<iostream>
using namespace std;
int main()
{
double num_1,num_2,num_3,max_number;
cout<<"Enter 1st Number = ";
cin>>num_1;
cout<<"Enter 2nd Number = ";
cin>>num_2;
cout<<"Enter 3rd Number = ";
cin>>num_3;
if(num_1 > num_2 && num_1 > num_3)
{
max_number=num_1;
cout<<"1st Number is Maximum"<<" and number is = "<<num_1<<endl;
}
else if(num_2 > num_1 && num_2 > num_3)
{
max_number=num_2;
cout<<"2nd Number is Maximum"<<" and number is = "<<num_2<<endl;
}
else if(num_3 > num_2 && num_3 > num_1)
{
max_number=num_3;
cout<<"3rd Number is Maximum"<<" and number is = "<<num_3<<endl;
}
else
cout << "Invalid Statement." << endl;
return 0;
}

No comments:

Post a Comment