Monday, August 29, 2011

Greater Number

Problem: Find which number is greater.


Algorithm:
1. Prompt for two numbers.
2. Make a decision of which number is greater.
3. Print the appropriate message.

Source Code:
#include<iostream>
#include<conio.h>
using namespace::std;
int main (void)
{
    int x,y;
    cout<<"Enter two numbers: ";
    cin>>x>>y;
    if
    (x>y)            //if x is greater
    cout<<x<<" is greater than "<<y<<endl;
    else if
    (x<y)            //if y is greater
    cout<<y<<" is greater than "<<x<<endl;
    else if (x==y)    //if both are equal
    cout<<"The numbers you entered are equal "<<endl;
    getch();
    return 0;
}

0 response(s):

Respond to this Post

Your participation is appriciated...