Answers for "how to find the maximum of numbers in c++"

C++
0

how to determine the highest number in c++

#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;
}
Posted by: Guest on April-19-2021
2

c++ how to get maximum value

x = 1, y  = 2;
fmax(x , y);
//if you want to print it right away:
cout << fmax(x , y);
//if you want to store it:
int j = fmax(x, y);
cout << j;

//output 2
Posted by: Guest on April-06-2021

Code answers related to "how to find the maximum of numbers in c++"

Browse Popular Code Answers by Language