Pascal · lesson 12 of 30 · Decisions and loopsA loop in a loop
The inner loop prints one row, the outer loop starts the next one.
12-table.pas Download 12-table.pas
program Table;
var
Row, Col: Integer;
begin
for Row := 1 to 6 do
begin
for Col := 1 to 6 do
Write(Row * Col:4);
WriteLn;
end;
end.
Terminal
$ ./12-table
1 2 3 4 5 6
2 4 6 8 10 12
3 6 9 12 15 18
4 8 12 16 20 24
5 10 15 20 25 30
6 12 18 24 30 36Exercise
Print the table up to 10 with a header row.