194k views
0 votes
Define a function named MaxMagnitude with two integer parameters that returns the largest magnitude value. Write a program that reads two integers from a user, calls function MaxMagnitude() with the inputs as arguments, and outputs the largest magnitude value.

1 Answer

6 votes

Answer:

You never said which language so I assumed python since most people start off with python first.

Step-by-step explanation:

# Define the MaxMagnitude function

def MaxMagnitude(a, b):

if abs(a) > abs(b):

return a

else:

return b

# Read two integers from the user

a = int(input("Enter the first integer: "))

b = int(input("Enter the second integer: "))

# Call the MaxMagnitude function to find the largest magnitude value

largest_magnitude = MaxMagnitude(a, b)

# Output the largest magnitude value

print("The largest magnitude value is:", largest_magnitude)

User SeasonalShot
by
7.6k points