Program to find greatest of 2 numbers [c++]

This program will take 2 numbers as input from the user and will display the number which is greater of the 2.

We will be displaying program which is compatible with Dev C++.

You can download dev c++ from here

 

Program Code:

 

 

#include<iostream.h>
#include<conio.h>
using namespace std;
int main()
{
int a,b;
cout<<"Enter the two numbers.\n";
cin>>a>>b;
if(a>b)
cout<<"The greater of the two number is "<<a;
else if(b>a)
cout<<"The greater of two numbers is "<<b;
else if(a==b)
cout<<"Numbers are equal!";
getch();
}

 

Output:

Greatest of 2 numbers

Leave a Reply

Your email address will not be published.