- Home
- Course Category
- Course Result
- Course Detail
Hot Line: 0124-2383121
Course Introduction
Programs for practice
In the program below, we've taken 3 numbers from user and printed the largest of them in C++
Source Code: Print Largest of Three Numbers
/* C++ Program - Find Largest of Three Numbers */
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a, b, c, large;
cout<<"Enter three numbers : ";
cin>>a>>b>>c;
//let a is the largest
large=a;
if(large<b)
{
if(b>c)
{
large=b;
}
else
{
large=c;
}
}
else if(large<c)
{
if(c>b)
{
large=c;
}
else
{
large=b;
}
}
else
{
large=a;
}
cout<<"Largest number is "<<big;
getch();
}
Output
Enter three numbers:
2
5
1
Largest number is 5