CJCoding With Joseph
15free / daySign inCreate account

Absolute Value

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

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

Expected Output:

7

= newline. No newline after the last line.

Hints3 available
Topics:
If Statements
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · 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.