Chapter 4 Outcomes
Control Constructs
Knowledge Outcomes
Define each of the key terms listed in the chart below.
| structured statements | control constructs | linear sequence |
| repetition | selection | structured programming |
| flow of control | flow charts | structure charts |
| landscape chart | flow of data | scope |
| loop index | by clause of a loop | decreasing clause |
| range of the loop | nested loop | invariant |
| proof by induction | then clause | else clause |
| cascaded if | desk checking | debugging |
| case construct | label statement | otherwise clause |
| off-by-one errors | subrange | forgiving programs |
State and define the three types of control constructs that form the basis of structured programming languages (4.1).
Explain why flow charts are not really necessary when using well structured languages (4.1).
Discuss the advantage of single entry and single exit from the three basic control constructs (4.1).
Describe the purpose of structure charts and landscapes when used to document objects or subprograms (4.1).
Explain the advantages and disadvantages of the index of a counted loop (4.2).
Distinguish between the index, scope, and range of a loop (4.2).
Explain how the by and the decreasing clauses modify the behaviour of counted loops (4.2).
Explain how to write any program requiring a counted loop (for and end for) by using only the elements of a conditional loop (loop, exit when, end loop) (4.2).
Describe the general methodology and the type of test data used to ensure that a loop works properly (4.2).
Explain what the invariant condition is when proving loop correctness (4.2).
When the invariant is true within a loop, describe the logic when using proof by induction (4.2).
State where the flow of control will proceed when the condition being evaluated in a selection construct is true or it is false (4.3).
Describe how the control of program execution is transferred to procedures, and subsequently to other procedures nested within these procedures (4.4).
Describe how flow charts can help us to understand the flow of control within a program (4.5).
Using a diagram or an explanation, show how to properly nest control structures inside of other control structures (4.5).
State various methods (if, assert, subrange declarations, loops, correct data entry using strintok) that can be used to check for correct data input (4.8).
Describe a variety of techniques that allow you to recognize patterns in a strings (4.9). These techniques include:
Skills Outcomes
Describe how the example program "backward.t" reverses the letters of a word that has been input (4.2).
Use single and multiple exits from conditional or counted loops (4.2).
Use basic selection constructs (4.3) including:
Trace through and explain the workings of the "format1.t" program that reformats text so that there are a specific number of characters per line (4.3).
Trace the execution of a program by using desk checking techniques that show the intermediate values of variables and indices which occur as the sequence of instructions are executed (4.6).
Use the case construct as an alternate method of selection, using either single or multiple numbers or words as the selection criteria (4.7).