C++ Program to find Biggest of Three Numbers

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

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

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

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.

Share this Page

Meet the Author