Challenge: Absolute Value

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

Problem Statement

You need to create a function absolute which computes the absolute value of a given number.

Input

The input of the function is a number x of type Double whose absolute value you want to compute.

Output

The output will be the absolute value of x.

Sample Input

-5

Sample Output

5

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