Write a function MaxMagnitude() with two integer input parameters that returns the largest magnitude value. Use the function in a program that takes two integer inputs, and outputs the largest magnitude value.
Ex: If the inputs are:
5 7
the function returns:
7
-8 -2
-8
Note: The function does not just return the largest value, which for -8 -2 would be -2. Though not necessary, you may use the absolute-value built-in math function.
#include using namespace std;void MaxMagnitude(int userVal1, int userVal2) {if (abs(userVal1) > abs(userVal2)) {return userVal1;}else if (abs(userVal2) > abs(userVal1)) {return userVal2;}}/* Define your function here */int main() {int userVal1;int userVal2;cin >> userVal1 >> userVal2;/* Type your code here. Your code must call the function. */cout < maxmagnitude(userval1,="" userval2)=""><>/* Type your code here */return 0;}Please help me with this problem using c++.
void MaxMagnitude(int userVal1, int userVal2) {if (abs(userVal1) > abs(userVal2)) {return userVal1;}else if (abs(userVal2) > abs(userVal1)) {return userVal2;}}/* Define your function here */
int main() {
int userVal1;int userVal2;cin >> userVal1 >> userVal2;/* Type your code here. Your code must call the function. */
cout < maxmagnitude(userval1,="" userval2)=""><>/* Type your code here */
return 0;}
Please help me with this problem using c++.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here