Answer to Question #58192 in C++ for ibrahimsyed

Question #58192
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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS