C++ Program to find Biggest of Three Numbers
You are Here:
Find Biggest of Three Numbers
In the following example, we will find which of the following numbers (40, 25, 7) is the biggest number.
Example
C++ Compiler
#include <iostream>
using namespace std;
int main()
{
int a = 40;
int b = 25;
int c = 7;
cout << "The numbers are a = " << a <<", b = " << b <<", c = " << c;
if((a > b) && (a > c))
cout << "\na = " << a <<" is the biggest number";
else if(b > c)
cout << "\nb = " << b <<" is the biggest number";
else
cout << "\nc = " << c <<" is the biggest number";
return 0;
}
Output
The numbers are a = 40, b = 25, c = 7
a = 40 is the biggest number
Find Biggest of any Given Three Numbers
In the following example, we will find the biggest of any given three numbers.
Example
C++ Compiler
#include <iostream>
using namespace std;
int main()
{
int a, b, c;
cout << "Enter an integer for a = ";
cin >> a;
cout << "Enter an integer for b = ";
cin >> b;
cout << "Enter an integer for b = ";
cin >> c;
if((a > b) && (a > c))
cout << "\na = " << a <<" is the biggest number";
else if(b > c)
cout << "\nb = " << b <<" is the biggest number";
else
cout << "\nc = " << c <<" is the biggest number";
return 0;
}
Output
Enter an integer for a = 2
Enter an integer for b = 5
Enter an integer for b = 7
c = 7 is the biggest number
In the following example, we will get three inputs from the user simultaneously and display the biggest among those.
Example
C++ Compiler
#include <iostream>
using namespace std;
int main()
{
int a, b, c;
cout << "Enter three integers: ";
cin >> a >> b >> c;
cout << "\n";
if((a > b) && (a > c))
cout << a <<" is the biggest number";
else if(b > c)
cout << b <<" is the biggest number";
else
cout << c <<" is the biggest number";
return 0;
}
Output
Enter three integers: 3 6 2
6 is the biggest number
Reminder
Hi Developers, we almost covered 90% of String functions and Interview Question on C++ with examples for quick and easy learning.
We are working to cover every Single Concept in C++.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.