C++ Program to Find Maximum of Two Numbers
Write C++ Program to Find Maximum of Two Numbers
//CPP Program to Find Maximum of Two Numbers #include <iostream> using namespace std; int main() { int n1, n2; cout << "Enter the number 1 :--> "; cin >> n1; cout << "Enter the number 2 :--> "; cin >> n2; if(n1 > n2) { cout << "\nThe largest number among " << n1 << " and " << n2 << " is " << n1; } else { cout << "\nThe largest number among " << n1 << " and " << n2 << " is " << n2; } return 0; }
Output:
Run 1:
Enter the number1 :--> 89
Enter the number2 :--> 98
The largest number among 89 and 98 is 98
Run 2:
Enter the number1 :--> 98
Enter the number2 :--> 89
The largest number among 98 and 89 is 98