Write a c++ program that asks the user to enter a first number and then a second number and then displays the bigger number with a statement, then calculates the maximum inside a function which must be called theMax and must not have any inside console input or output.
1
Expert's answer
2016-03-09T09:04:05-0500
#include <iostream>
using namespace std;
int theMax(const int first, const int second) { return first > second ? first : second; }
int main() { int a, b; cout << "Enter first number: "; cin >> a; cout << "Enter second number: "; cin >> b; int max = theMax(a, b); cout << "Max(" << a << ", " << b << ") = " << max << endl; system("pause"); return 0; }
Comments
Leave a comment