← Back to If Statements
Question 323
Absolute Value
Absolute Value
An integern = -7is given. Print its absolute value (its distance from zero) using anifstatement (see Expected Output). Do not use theabslibrary function and do not hardcode7. Ifnis negative, print-n; otherwise printn.
Expected Output:
7= newline. No newline after the last line.
Hints3 available
Sign in to use hintsTopics:
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.