Chapter 7 Outcomes
The Elements of Programming: Counted Repetition
Knowledge Outcomes
Define each of the key terms listed in the chart below.
| counted loop | initialization in declaration | index of counted loop |
| decreasing | for and end for | range |
| local variables | step size | by |
| character graphics | locate | nested loop |
| paragraphing a program | color in graphics | color monitor |
| colorNumber | colorback | background color |
| function | repeat | echo input |
| string input | token |
Describe the purpose of the index in a counted loop.
Explain why it is not necessary to include the data type when declaring a variable if the variable is being initialized with a value.
Describe the range of a counted loop.
State the value of the index each time the loop is executed.
Describe the circumstance which makes a variable local
State the data type which a variable automatically becomes when it appears after the keyword for.
Compare and contrast the counted loop program "avgfive" with conditional loop program "avg5" for each of the following constructs:
Describe the origin and size (based on rows and columns) of the character graphic window.
Explain why two dots must follow the put instruction when outputing characters using the locate instruction (for earlier versions of the Turing Interpreter).
Explain how the inner loop is affected by the outer loop when loops are nested.
Explain why nested loops cannot have the same index variable.
State the advantages of using an exit when condition in a counted loop.
Skills Outcomes
Create a regular loop that is able to count by using a variable in combination with the loop and end loop construct along with the exit when.
Create a counted loop that counts backwards by using the keyword decreasing.
Create a counted loop that uses the keyword by to change the step size of the index.
Modify a regular loop to use a different increment value.
Modify a regular loop such that it can be made to count backwards.
Use the locate instruction to output a character anywhere in the execution window.
Change the color of characters by using the color instruction.
Show how to cause a character to blink.
Affect the background color of a character by using the colorback instruction.
Combine the properties of a counted loop with a conditional loop by using an exit when in the body of the counted loop.
Create a nested loop.
Use the repeat function to produce a pattern that is repeated a given number of times.
Detect and correct a variety of common errors when creating counted loops as outlined in the chapter.