In this tutorial you will learn about the C++ Program to Find Largest Number Among Three Numbers and its application with practical example.
C++ Program to Find Largest Number Among Three Numbers
In this tutorial, we will learn to create a C++ program that will find Largest Number Among Three Numbers using C++ programming.
Before starting with this tutorial we assume that you are best aware of the following C++ programming topics:
- Operators in C++ Programming.
- Basic Input and Output function in C++ Programming.
- Basic C++ programming.
- Conditional statement in C++ programming.
Program to Find Largest Number Among Three Numbers
In c++ programming, it is possible to take numerical input from the user and find Largest Number Among Three Numbers with the help of a very small amount of code. The C++ language has many types of header libraries which has supported function in them with the help of these files the programming is easy. But today we will find Largest Number Among Three Numbers using c++ programming.
With the help of this program, we can find Largest Number Among Three Numbers.
1. Declaring the variables for the program.
2. Taking the input numbers.
3. Checking the greatest number.
4. Printing the greatest number.
5. End the program.
Program to find the Smallest of Three Numbers:-
using namespace std;
//declaring the variables for the program.
float no1, no2, no3;
no1, no2, no3 will hold
the values of three numbers
from the user taken in the input
//Taking the input from the user three numbers
cout << "Enter three numbers for comparision: ";
cin >> no1 >> no2 >> no3;
if(no1 >= no2 && no1 >= no3)
cout << "Largest number: " << no1;
if(no2 >= no1 && no2 >= no3)
cout << "Largest number: " << no2;
if(no3 >= no1 && no3 >= no2)
cout << "Largest number: " << no3;
In the above program, we have first initialized the required variable.
- no1 = it will hold the integer value.
- no2 = it will hold the integer value.
- no3 = it will hold the integer value.
Input numbers for the program.
Program Logic Code.
Printing output for the greatest number.