# Largest Amongst Three Numbers

Largest Amongst Three Numbers” is very basic programming Exercise problem. Here, we are given three numbers, entered by user and our task is to write a program to find the largest amongst three number.

Example (Largest Amongst Three Numbers):

```INPUT:
Num1 = 10
Num2 = 20
Num3 = 30
OUTPUT
30 is largest number```

As we have only three numbers, we will simply check every number with other two remaining number to find the largest amongst three numbers.

#### C++ Program to find largest amongst three numbers is as follows:

```/* C++ Program to find largest amongst three numbers  */
#include<bits/stdc++.h>
using namespace std;
int main()
{
int num1,num2,num3;

// Scanning the numbers
cout<<"Enter the first Number: ";
cin>>num1;

cout<<"Enter the second Number: ";
cin>>num2;

cout<<"Enter the third Number: ";
cin>>num3;

int largest;

// check if first number is largest
if(num1 >= num2 && num1 >= num3)
{
largest = num1;
}
// check if second number is largest
else if(num2 >= num1 && num2 >= num3)
{
largest = num2;
}
// check if third number is largest
else if(num3 >= num1 && num3 >= num2)
{
largest = num3;
}

//Printing the largest number
cout<<"The largest number is "<<largest;
}

```
```OUTPUT:
Enter the first Number: 10
Enter the second Number:  20
Enter the third Number: 30
The largest number is 30```

Related Posts: