codescracker


c++

C++ Program to Find Largest of Three Numbers



« Previous Program Next Program »


Find Largest of Three Numbers in C++

To find the largest number among the three numbers in C++ programming, you have to ask to the user to enter the three numbers, now start checking which one is the largest number. After finding the largest, display that number as the largest number among the three numbers on the output screen as shown here in the following program.

C++ Programming Code to Find Largest of Three Numbers

Following C++ program ask to the user to enter the three numbers to check which one is the largest or the biggest one of the three numbers, then display the result on the screen :

/* C++ Program - Find Largest of Three Numbers */
		
#include<iostream.h>
#include<conio.h>
void main()
{
	clrscr();
	int a, b, c, big;
	cout<<"Enter three numbers : ";
	cin>>a>>b>>c;
	//let a is the biggest
	big=a;
	if(big<b)
	{
		if(b>c)
		{
			big=b;
		}
		else
		{
			big=c;
		}
	}
	else if(big<c)
	{
		if(c>b)
		{
			big=c;
		}
		else
		{
			big=b;
		}
	}
	else
	{
		big=a;
	}
	cout<<"Biggest number is "<<big;
	getch();
}

When the above C++ program is compile and executed, it will produce the following result. Above C++ Programming Example Output (for c):

C++ program find biggest of three

Above C++ Programming Example Output (for b):

C++ program find largest of three

Above C++ Programming Example Output (for a):

C++ program find largest in three

Same Program in Other Language

You may like the same program in other programming languages:


« Previous Program Next Program »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test