COMP2243 - Programming and Problem Solving

Syllabus Software Installation Assignments Tests
Lectures and Labs
**Back to Full Menu**

Repetitions/Loops WhileLoop.java LoopWithCounter.java LoopWithSentinel.java LoopWithFlag.java SimpleInterest.java Factorial.java Fibnonacci.java PrimeNumber.java GCD.java PopulationGrowth.java ForLoop.java DoWhileLoop.java FileIO_Tickets.java FileIO_Salary.java NestedLoop.java



NestedLoop Program


Description

This program uses several nested loops to print some geometry patterns.

Associated Concepts:

Nested loop

Algorithm:

Use a nested loop to print a 12 X 10 pattern of *

Outer loop: number of rows
    Inner loop: number of columns


Use another nested loop to print a triangle pattern of *
The first row has one *, the second row has two *, and so on.

Outer loop: number of rows
    Inner loop: number of columns
    The length of column depends on the row.


Use another nested loop to print a triangle pattern of *
The first row has twelve *, the second row eleven *, and so on.

Outer loop: number of rows
    Inner loop: number of columns
    The length of column depends on the row.

Source Code



Sample Run




Video