Friday, 5 July 2013

Accept three numbers from a user and find the greatest of the three.

#include<iostream>
using namespace std;
int main()
{
float a,b,c;
cout<<"Enter the first number: ";
cin>>a;
cout<<"Enter the second number: ";
cin>>b;
cout<<"Enter the third number: ";
cin>>c;
if(a>=b)
{
if(a>=c)
{
cout<<a<<" is the biggest number.";
}
else
cout<<c<<" is the biggest number.";
}
else if(b>=c)
{
cout<<b<<" is the biggest number.";
}
else
{
cout<<c<<" is the biggest number.";
}
}

No comments:

Post a Comment