C++

Finding the Largest of Two Numbers in C++ (Entered by User)

To determine which of two values entered by the user is the largest, we are utilizing an if..else statement in this application.

Program to determine the larger of two entered numbers, for instance

#include <iostream>
using namespace std;

int main()
{
    int num1, num2;
    cout<<"Enter first number:"; 
    cin>>num1;
    cout<<"Enter second number:"; 
    cin>>num2;
    if(num1>num2)
    {
	cout<<"First number "<<num1<<" is the largest";
    }
    else
    {
	cout<<"Second number "<<num2<<" is the largest";
    }
    return 0;
}

Output:

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button