C++ Program to find the maximum of three numbers [DEVCPP/GCC]


//Program to find maximum among three numbers

#include <iostream>

using namespace std;

int main()
{
        float a,b,c,max;

        cout<<"ENTER FIRST NUMBER: ";
        cin>>a;
        cout<<"ENTER SECOND NUMBER: ";
        cin>>b;
        cout<<"ENTER THIRD NUMBER: ";
        cin>>c;

        if(a>b)            //Comparing first two numbers (a & b)
max=a;
else
max=b;

if(c>max)      //Comparing the max of above two numbers from the third number
max=c;


        cout<<"\nMAXIMUM AMONG "<<a<<","<<b<<","<<c<<" IS:"<<max;

        return 0;
}



Share this

Related Posts

FIND US ON FACEBOOK!