CJCoding With Joseph

Absolute Value

An integer n = -7 is given. Print its absolute value (its distance from zero) using an if statement:

7

Do not use the abs library function and do not hardcode 7. If n is negative, print -n; otherwise print n.

Expected Output:

7
Topics:
If Statements
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (p, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.