- Related Questions & Answers
- C program to Find the Largest Number Among Three Numbers
- Java program to Largest number among three numbers
- How to Find the Largest Among Three Numbers using Python?
- Program to find largest of three numbers - JavaScript
- C++ program to find the smallest element among three elements
- Java program to find largest of the three numbers using ternary operators
- Largest N digit number divisible by given three numbers in C++
- C# program to find the maximum of three numbers
- Java program to find maximum of three numbers
- Program to find the common ratio of three numbers in C++
- Python program to find the maximum of three numbers
- Program to find the Largest Number using Ternary Operator in C++
- Largest Multiple of Three in C++
- C Program for Find largest prime factor of a number?
- Python program to find largest number in a list

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

The largest number among three numbers can be found using if statement multiple times. This is given in a program as follows −

#include <iostream> using namespace std; int main() { int a = 5 ,b = 1 ,c = 9; if(a>b) { if(a>c) cout<<a<<" is largest number"; else cout<<c<<" is largest number"; }else { if(b>c) cout<<b<<" is largest number"; else cout<<c<<" is largest number"; } return 0; }

9 is largest number

In the above program, firstly, a is compared to b. If a is greater than b, then it is compared to c. If it is greater than c as well, that means a is the largest number and if not, then c is the largest number.

if(a>b) { if(a>c) cout<<a<<" is largest number"; else cout<<c<<" is largest number"; }

If a is not greater than b, that means b is greater than a. Then b is compared to c. If it is greater than c, that means b is the largest number and if not, then c is the largest number.

else { if(b>c) cout<<b<<" is largest number"; else cout<<c<<" is largest number"; }

Advertisements