04 Try it yourself Interactive

Watch the same grid fill in two different orders

The 3 × 3 from section 02, one cell per press of Next. Green cells have been read, the indigo cell is being read right now, and the amber band shows the row or column the outer loop currently owns. Watch the two indices in the stat row: in row-major r holds still while c races, and in column-major it is the other way round. Whichever matrix you load, the running total lands on the same number both ways — on the 3 × 3 that number is 24.

Row-major
outer r, inner c → row sums
Rows separated by a semicolon, cells by spaces. Up to 5 rows and 6 columns.
Press Next to begin. Each press is one move: the outer loop taking a row or column, a single cell being read, or a finished sum being stored.


      
Row r
Column c
Running total0
Cells read0
step 0 / 0