Answer:
The function requires evaluate the largest magnitude (the largest value withou sign), so we need to compare the absolute value of the two inputs number. For that we use the abs() function.
The code is as follows, with the comments after // and in italic font:
#include <iostream> <em>//module for input/output stream objects</em>
#include <cmath> <em>//math module </em>
using namespace std;
<em>// follows the function definition </em>
int MaxMagnitude (int userVal1, int userVal2) {
int Max=0; <em>//define output variable Max</em>
if (abs(userVal1) > abs(userVal2)) { <em>// compare magnitude
</em>
Max = userVal1; <em> //if Val1 is larger than val2 Max is Val1</em>
}
else {
Max = userVal2; <em>//else the max is Val 2
</em>
}
return Max; <em>//the value returned for this function</em>
}
// <em>in main we will use the defined function MaxMagnitude</em>
int main() {
int one = 0;
int two = 0;
cin >> one; //assignation of the first user input to one
cin >> two; //assignation of the second user input to two
//we call the function using as input the read values
//and write the return of the function, all at once
cout << MaxMagnitude(one, two) << endl;
return 0;
}