129k views
2 votes
Design a function named "max" that accepts two integer values as arguments and returns the value that is the greater of the two. For example, if 7 and 12 are passed as arguments to the function, the function should return 12. Use the function in a program that prompts the user to enter two integer values. The program should display the value that is the greater of the two.

User Phreakhead
by
5.5k points

2 Answers

3 votes

Answer:

#section 1

def max(int1, int2):

if a > b:

return a

else:

return b

#section 2

print("------Enter Two Integers----------\\\\")

a = int(input('Enter First Integer:'))

b = int(input('Enter Second Integer'))

print(max(a, b))

Step-by-step explanation:

The programming language used is python 3.

#section 1

The function is defined and it has two parameters (int1 and int2) that allows it to take two arguments.

The IF and ELSE statements compares both parameters and return the highest.

#section 2

A program is written to prompt the user for two inputs, and converts them to an integer, passes it to the max function and prints the result to the screen

Design a function named "max" that accepts two integer values as arguments-example-1
User Lloydworth
by
5.6k points
0 votes

// writing c++ function

int maximum ( int a , int b){

if(a>b)

return a;

else

return b;

}

//when this function will be called it will return the max of the integers sent.

//for example

int max = maximum ( 3,4)

//max variable will have 4 returned by the function

User Soony
by
4.9k points