Programming Course for Beginners - ZedLX

The Easiest Online Computer Programming Course, for Free

Nested Loops and Alignment [3/10]

Why not print the whole multiplication table?

A for loop can be used to repeat the piece of code that prints a single line of multiples.

Nesting one loop inside another creates a double loop.

A double loop consists of an outer loop and an inner loop.

In this example, the outer for loop repeats 10 times a piece of code that prints out multiples of number 6.

Can you modify this program so that each row prints multiples of a different number? The first row should print multiples of number 1, the second row multiples of 2 and so on.

Hint: What is the name of the control variable of the outer for loop?

Solution (click):

: print j*i," ";

Loading...