# C++ Program to Find Largest of Three Numbers Using IF-ELSE

C++ Program to Find Largest of Three Numbers Using If-Else Statements. Write a program to find the largest of three numbers in C++. Largest of 3 numbers. Logic Is very simple just follow the below simple steps. as we know there are 3 numbers which means one number is greater than the rest of the two numbers so for this problem, we can take an example and with help of an example, we can find the greatest or biggest and largest number among three numbers.

Note: This program may misbehave if you change the data type of number, For running and executing this program all data types should be the same. Ex float, long and double.

## C++ Program to Find Largest of Three Numbers Using IF-ELSE

``````#include <iostream>
using namespace std;
int main()
{
int a, b, c;

cout << "Enter The 3 Numbers :\n\n";
cin >> a >> b >> c;

if (a > b && a > c)
{
cout << "First Number is Largest \n";
}
else if (b > a && b > c)
{
cout << "Second Number is Largest \n";
}
else if (c > a && c > b)
{
cout << "Third Number is Largest \n";
}
else
cout << "All Numbers Are Equal \n";
return 0;

}``````

### Find the Largest of Three Numbers

Step 1

So for this problem, we are taking three numbers 10, 20, and 30. If the first number is greater than the remaining two then print the first one in greater, so according to steps 1 - 10 is not greater than 20 and 30 so the first step is not working now follow step 2.

Step 2

If the Second number is greater than the remaining two then print the Second one in greater, so according to step 2 - 20 is greater than 10 but not greater than 30 so the step fails now follow step 3.

Step 3

If the Third number is greater than the remaining two then print the Third one in greater, so according to steps 1 and step 2 - 30 is greater than 20 and 10 here step 3 working now no need to perform step 4, we get our answer and program will print "Third Number is Greatest".

Step 4

If step 1 to step 3 is not true then all three numbers are equal. This is a special case if all numbers are equal. For this step, if all three numbers are equal like 10, 10, and 10 then the program will print "All Numbers Are Equal".

### The Output of the Largest of Three Numbers in C++

Previous Post
Next Post

#### post written by: Ghanendra Yadav

Hi, I’m Ghanendra Yadav, SEO Expert, Professional Blogger, Programmer, and UI Developer. Get a Solution of More Than 500+ Programming Problems, and Practice All Programs in C, C++, and Java Languages. Get a Competitive Website Solution also Ie. Hackerrank Solutions and Geeksforgeeks Solutions. If You Are Interested to Learn a C Programming Language and You Don't Have Experience in Any Programming, You Should Start with a C Programming Language, Read: List of Format Specifiers in C.