5.19 · exercise
The multiplication table
Print the n-by-n multiplication table, rows of row * col padded into neat columns. The starter reads n.
The shape is two nested loops: 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.
printf is free to overwrite x9 through x15, so keep both counters in row_r and col_r. The starter gives those names to x19 and x20, which printf must hand back unchanged.
What is checked
- four rows of four aligned products for the
4in the stdin box - the program exits cleanly
- the products come from
mulinside the loops - the same holds for other sizes you do not see, down to a one-by-one table
specification
stdin4
stdoutprints the right output
exitexits with the right code
sourceuses
mulsourceuses
cmphiddenright output and exit code on 4 more inputs you do not see
We run your program on the input above and on the hidden ones, and compare what it does. Nothing is matched against a stored solution.