Welcome

Hi! This blog is for beginners of c++ and java .You can check and pick codes for your programming assignments. This will also help you to understand the concepts of these programming languages. Its all about programming.

If Else Practice(Max , Min OR Equal in three numbers)

Wednesday, May 18, 2011

#include <iostream.h>
#include <conio.h>
int main ()
{
    clrscr();
    int a,b,c;
    cout <<"Enter Your First Number : ";
    cin >> a;
    cout <<"\nEnter Your Scond Number : ";
    cin >> b;
    cout <<"\nEnter Your Third Number : ";
    cin >> c;
    cout <<endl;
    if (a>b && b>c && a>c) //just like 5,4,3.
    {
        cout << a <<" Is Maximum And " << c <<" Is Minimum" <<endl;
    }
    else if (a<b && b>c && c<a) //just like 4,5,3.
    {
        cout << b <<" Is Maximum "<< c <<" Is Munimum" <<endl;
    }
    else if (a<b && b<c && a<c) //just like 3,4,5.
    {
        cout << c <<" Is Maximum "<< a <<" Is Minumum" <<endl;
    }
    else if (a>b && b<c && c>b)  //just like 4,3,5.
    {
        cout << c <<" Is Maximum "<< b <<" Is Minimum" <<endl;
    }
    else if (a>b && b<c && c<a) //just like 5,3,4.
    {
        cout << a <<" Is Maximum "<< b <<" Is Minimum" <<endl;
    }
    else if (a<b && b>c && c>a)  //just like 3,5,4.
    {
        cout << b <<" Is Maximum "<< a <<" Is Minimum" <<endl;
    }
    else if (a==b && b==c)  //if all are not true
    {
        cout << a <<" , "<< b <<" And "<< c <<" Are Equal" <<endl;   //just like 3,3,3.
    }
    else if (a==b && a>c)
    {
        cout << a <<" And " << b <<" Are equal and "<< c <<" is less then both "<<endl;
    }
    else if (a==b && a<c)
    {
        cout << a <<" , " <<b <<" Are equal and "<<c <<" is greater then both"<<endl;
    }
    else if (a==c && b>c)
    {
        cout << a <<" , " <<c <<" Are equal and " <<b <<" is greater then both "<<endl;
    }
    else if (a==c && a<b)
    {
        cout <<a <<" , " <<c <<" Are equal and " <<b <<" Is less then both "<<endl;
    }
    getch();
    return 0;
}