5.12 · exercise

pick the bigger one

Two contenders sit in registers. Print the larger one.

A clean pattern: assume one of them is the winner, then compare and replace the assumption only when the other is bigger. That way there is exactly one branch to reason about.

what is checked

  • the larger value is printed on its own line
  • the program exits cleanly
  • a comparison decides it

Specification

args
stdoutprints the expected output
exitexits with the expected code
sourceuses cmp

Checked by running your program against expected behavior, never by matching a stored solution.

loading editor...
Open in playground