C++ Program to Find Greatest of Two Numbers
Program to find the Greatest of two numbers
Here we will discuss how to find the greatest of two numbers entered by the user in c++ programming language.
To find greatest of two numbers the use of if else statement is required along with the relational operator ‘>’
- Two inputs are taken from user.
- The inputs are stored in two int type variables say first and second respectively.
- The two inputs are compared using the if else statement with the condition:
if( first > second )
- If the above mentioned condition is true then first is greater than the second.
Otherwise second is greater than the first.
//Greatest of two numbers
using namespace std;
cout<<"Enter first number: ";
cout<<"Enter second number: ";
cout<<"both are equal";
cout<<first<<" is greater than "<<second;
cout<<second<<" is greater than "<<first;
Enter first number: 11
Enter second number: 97
97 is greater than 11