PATH: Instructional Server> COP 2000> Examples> Repetition>

Outlined Algorithms for Counting Repetition Structures


This web page contains text-based alternatives to the final flowchart illustration shown in the web page The Repetition Control Structure (a.k.a. Looping). That illustration offers examples of two different control structures, "leading decision" repetition and "trailing decision" repetition. The first outline on this web page relates to the leading decision loop example. The final outline relates to the trailing decision loop example.

Trailing Decision Loop Algorithm Outline (alternative to a flowchart)

It is important to clearly describe logical control structures that involve branching away from the simple sequential flow of steps and the conditions upon which they are based. Outlines are well suited to this task because of the hierarchical nature of their lettered and numbered steps. Analysts often employ indentation using tabs or spaces to help clarify step subordination. If your rendering software cannot indicate the presence of such "whitespace" characters, be give careful attention to the labeling of the steps to determine the subordination of the steps.

Note: in the document below, "[CR]" represents the carriage return and/or line feed sequence necessary to start a new line of output.

A. Start "Trailing Decision Counting Loop Example"
B. Assign 1 into C. ("Initialization of the counter")
C. Do a loop pass:
   C.1. Display the string "Hello" and a [CR]. ("Loop body")
   C.2. Replace counter C with a value 1 greater. ("Loop increment")
   C.3. If C is less than or equal to 5 ("Test for passage/exit"), do another loop pass.
D. End

Leading Decision Loop Algorithm Outline (alternative to a flowchart)

It is important to clearly describe logical control structures that involve branching away from the simple sequential flow of steps and the conditions upon which they are based. Outlines are well suited to this task because of the hierarchical nature of their lettered and numbered steps. Analysts often employ indentation using tabs or spaces to help clarify step subordination. If your rendering software cannot indicate the presence of such "whitespace" characters, be give careful attention to the labeling of the steps to determine the subordination of the steps.

Note: in the document below, "[CR]" represents the carriage return and/or line feed sequence necessary to start a new line of output.

A. Start "Leading Decision Counting Loop Example"
B. Assign 1 into C. ("Initialization of the counter")
C. While C is less than or equal to 5 ("Test for passage/exit"), do a loop pass:
   C.1. Display the string "Hello" and a [CR]. ("Loop body")
   C.2. Replace counter C with a value 1 greater. ("Loop increment")
   C.3. Go back to loop test. ("Loopback")
D. End
PATH: Instructional Server> COP 2000> Examples> Repetition>