Skip to Content
Absolute Beginner's Guide to Programming, Third Edition
book

Absolute Beginner's Guide to Programming, Third Edition

by Greg Perry
November 2002
Beginner content levelBeginner
432 pages
11h 44m
English
Que
Content preview from Absolute Beginner's Guide to Programming, Third Edition

Nested Loops

A bubble sort requires a nested For loop. As with the If statement, you can nest one loop inside another. Anytime your program needs to repeat a loop more than once, use a nested loop. Figure 12.3 shows an outline of a nested For loop. Think of the inside loop as looping faster than the outside loop. The inside loop iterates faster because the Inner variable goes from 1 to 10 in the inside loop before the outside loop's first iteration is completed. Because the outside loop does not repeat until the Next Outer statement, the inside For loop has a chance to finish. When the outside loop finally does iterate a second time, the inside loop starts all over again.

Figure 12.3. The outer loop determines how many times the inner loop executes. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Absolute Beginner's Guide to Programming, Second Edition

Absolute Beginner's Guide to Programming, Second Edition

Greg Perry

Publisher Resources

ISBN: 0789729059Purchase book