Write a C++ program to find the largest number among three numbers

Configurare noua (How To)

Situatie

A number will be largest if number is greater than both the other numbers.

Backup

#include <iostream>
using namespace std;
int main() {
float a, b, c;
cin >> a >> b >> c;
if(a >= b && a >= c)
    cout << "Largest number: " << a;
if(b >= a && b >= c)
    cout << "Largest number: " << b;
if(c >= a && c >= b)
    cout << "Largest number: " << c;
return 0;
}
Input: 1 2 3
Largest number: 3

Solutie

Tip solutie

Permanent

Voteaza

(6 din 14 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?