Tuesday, November 20, 2012

C++: Maximum of three numbers


#include <iostream.h>

int main()
 {
    float a, b, c;
    cout<<"Enter the first number"<<endl<<"a=";
    cin>>a;
    cout<<endl<<"Enter the second number"<<endl<<"b=";
    cin>>b;
    cout<<endl<<"Enter the third number"<<endl<<"c=";
    cin>>c;
    if (a>b)
    {
        if (a>c)
            cout<<endl<<a<<" is the gratest"<<endl;
        else
            cout<<endl<<c<<" is the gratest"<<endl;
    }
    else
    {
        if (b>c)
            cout<<endl<<b<<" is the gratest"<<endl;
        else
            cout<<endl<<c<<" is the gratest"<<endl;
    }


 return 0;
 }

No comments:

Post a Comment