Program to check the largest number among three numbers

0 Suresh Chand March 28, 2021

In this example, We will learn how to check the largest number among three numbers using the C++ programming language.

To understand this example, You must have the knowledge of

In this example, We we will ask for three numbers and compare each numbers to get largest number. Let’s look an example to make clear concepts:

#include <iostream>
using namespace std;

int main() {    
    float n1, n2, n3;

    cout << "Enter three numbers: ";
    cin >> n1 >> n2 >> n3;

    if(n1 >= n2 && n1 >= n3)
        cout << "Largest number: " << n1;

    else if(n2 >= n1 && n2 >= n3)
        cout << "Largest number: " << n2;
    
    else
        cout << "Largest number: " << n3;
  
    return 0;
}

The output of above program is

Enter three numbers : 5, 7, 9
Largest Number: 9
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

Join Our Newsletter Now

Get the latest tutorials, examples and projects updates.

Ads Block Detector Powered by codehelppro.com

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Disable Ad Block

Want Same System