5.24 · exercise
the multiplication table
Print the four-by-four multiplication table, rows of row * col padded into neat columns.
This is the nested-loop kata: an outer loop over rows, an inner loop over columns, a mul in the middle, and a newline after each row. The cell format %4lld right-aligns every product into a four-character column so the table lines up.
One trap worth meeting on purpose: printf may scribble on the scratch registers, so both counters belong in the aliased callee-saved registers, not in x9.
what is checked
- four rows of four aligned products
- the program exits cleanly
- the products come from
mulinside the loops
Specification
args
stdoutprints the expected output
exitexits with the expected code
sourceuses
mulsourceuses
cmpChecked by running your program against expected behavior, never by matching a stored solution.
loading editor...