Tuesday, November 20, 2012

C++: Maximum of two numbers(function)

#include <iostream.h>

float greater(float, float);

int main()
 {
    float a, b, c, d, e;
    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;
    d = greater(a,b);
    e = greater(d,c);
    cout<<e<<" is the greatest number"<<endl;


 return 0;
 }
float grater(float x, float y)
{
    if (x>y)
        return x;
    else
        return y;

}

No comments:

Post a Comment