- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

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

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

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

## Example

#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; }

## Output

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"; }

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

Advertisements