Challenge: Max with Nested Functions

Test yourself and implement what you have learned so far in this chapter.

Problem statement

In this challenge, you need to create a nested function, max, which will be defined in the body of the function mainMax. mainMax returns the maximum of three numbers using the max function.

You will need to write the max function from scratch. Take some time and try to figure out how many parameters it should have and what the return value will be. You will also need to figure out what mainMax will return.

Input

The inputs of the mainMax function are three numbers a, b, and c of type int.

Output

The output will be the maximum of a, b, and c.

Sample input

mainMax(1,9,5)

Sample output

9

Test yourself

Write your code in the given area. Try the exercise by yourself first, but if you get stuck, the solution has been provided. Good luck!

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy