← Back to If Statements
Question 199
If: Absolute Value
If: Absolute Value
The variable number holds a negative value. Write an if statement that flips the sign of number when it is below zero, so that it becomes positive (this is the absolute value, done by hand). Then print the result with the label Absolute value: . A positive number must be left unchanged.Expected Output:
Absolute value: 8= newline. The output ends with a newline — print one 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 (clog, fn, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.