5.10 · exercise
the absolute truth
The value register starts at -42, and the program should print its magnitude: 42.
Compare the register against zero, skip the sign flip when it is already positive, and flip it otherwise. neg produces the negation of a register in one instruction.
Worth noticing once your solution passes: the same code must not damage a value that starts out positive. Change the starting value to 42 and run again to convince yourself.
what is checked
- the magnitude is printed on its own line
- the program exits cleanly
- the sign flip uses
neg
Specification
args
stdoutprints the expected output
exitexits with the expected code
sourceuses
negsourceuses
cmpChecked by running your program against expected behavior, never by matching a stored solution.
loading editor...