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...


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


Ex: If the inputs are:


-8 -2


the function returns:


-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++.



Jun 04, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here