CJCoding With Joseph
15free / daySign inCreate account

Absolute Value By Hand

Read a whole number and print how far it is from zero without calling abs(): a negative number is printed with its sign removed, any other number is printed as it is. Input: one integer, no prompt. Output: one line holding the distance.

Expected Output:

8

= newline. The output ends with a newline — print one after the last line.

Hints2 available
Topics:
If Statements
📥 Auto-Input:
-8\n
This input is automatically fed to your program's stdin
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.