# C++ Program to Find Largest Number Among Three Numbers

Problem:- Write A Program To Find Greatest or biggest or largest Of Three Number or Largest Number program in c or Largest Number program in c++ or C++ Program to Find Largest Number Among Three Numbers

Logic:- Logic Is very simple just follow the below simple steps. as we know there are 3 numbers that mean one number is greater than the rest of 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.

Step 1:-

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

Step 2:-

If the Second number is greater than 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 the step 3.

Step 3:-

If the Third number is greater than remaining two then print the Third one in greater, so according to step 1 and step 2 - 30 is greater than 20 and 10 here step 3 working now no need 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 number's are equal. This is a special case if all numbers are equal. For this step, if all three number are equal like 10, 10, 10 then the program will print "All Number Are Equal".

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

Solution:-

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

cout<<"Enter Three Number :\n\n";
cin>>a>>b>>c;

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

}

Output:-

Condition 1:-

Condition 2:-

You May Like This:-