Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
30 Cards in this Set
- Front
- Back
for statement
|
A for statement, or for loop, can be used to code definite loops. It contains a loop control variable that is automatically initializes, evaluates and alters.
|
|
step value
|
A step value is a number you use to increase a loop control variable on each pass through a loop
|
|
pretest loop
|
A pretest loop tests its loop control variable before each iteration, meaning that the loop body might never execute
|
|
posttest loop
|
A posttest loop tests its loop control variable after each iteration, meaning that the loop body executes at least one time
|
|
accumulator
|
An accumulator is a variable that you use to gather or accumulate values
|
|
summary report
|
A summary report list only totals, without individual detail records
|
|
Defensive programming
|
Defensive programming is a technique with which you try to prepare for all possible errors before they occure
|
|
validate data
|
To validate data is to ensure that data items are meaningful and useful. For examples, you ensure that values are the correct data type or that they fall within acceptable range
|
|
GIGO
|
Garbage in Garbage Out
means that if your input is correct, your output is worthless |
|
Forcing
|
Forcing a data item means you override incorrect data by setting it to s specific value.
|
|
1. The structure that allows you to write one set of instructions that operate on multiple, separate sets of data is the __________.
a. Sequence b. Selection c. Loop d. Case |
c. Loop
|
|
2. The loop that frequently appears in a program’s mainline logic __________.
a. Always depends on whether a variable equals 0 b. Works correctly based on the same logic as other loops c. Is an unstructured loop d. Is an example of an infinite loop |
b. Works correctly based on the same logic as other loops
|
|
3. Which of the following is not a step that must occur with every correctly working loop?
a. Initialize a loop control variable b. Set the loop control variable equal to a sentinel during each iteration c. Compare the loop control value to a sentinel during each iteration d. Alter the loop control variable during each iteration |
b. Set the loop control variable equal to a sentinel during each iteration
|
|
4. The statements executed within a loop are known collectively as the ________.
a. Loop body b. Loop controls c. Sequences d. Sentinels |
a. Loop body
|
|
5. A counter keeps track of _________.
a. The number of times an event has occurred b. The number of machine cycles required by a segment of a program c. The number of loop structures within a program d. The number of times software has been revised |
a. The number of times an event has occurred
|
|
6. Adding 1 to a variable is also called _______________ it.
a. Digesting b. Resetting c. Decrementing d. Incriminating |
d. Incriminating
|
|
7. Which of the following is a definite loop?
a. A loop executes as long as a user continues to enter valid data b. A loop executes 1000 times c. Both of the above d. None of the above |
b. A loop executes 1000 times
|
|
8. Which of the following is an indefinite loop?
a. A loop executes exactly 10 times b. A loop that follows a prompt that asks a user how many repetitions to make and uses the value to control the loop c. Both of the above d. None of the above |
b. A loop that follows a prompt that asks a user how many repetitions to make and uses the value to control the loop
|
|
9. When you decrement a variable, you _________
a. Set it to 0 b. Reduce it by one-tenth c. Subtract a value from it d. Remove it from a program |
c. Subtract a value from it
|
|
10. When the two loops are nested, the loop that is contained by the other is the _____ loop
a. Captive b. Unstructured c. Inner d. Outer |
c. Inner
|
|
11. When loops are nested, _______________________
a. They typically share a loop control variable b. One must end before the other begins c. Both must be the same type-definite or indefinite d. None of the above |
d. None of the above
|
|
12. Most programmers use a for loop _____
a. For every loop they write b. When a loop will not repeat c. When a loop must repeat many times d. When they know the exact number of times the loop will repeat |
d. When they know the exact number of times the loop will repeat
|
|
13. A report that lists only totals, with no details about individual records is a(n) ___________ report
a. Accumulator b. Final c. Summary d. Detailless |
c. Summary
|
|
14. Typically, the value added to a counter variable is ______________
a. 0 b. 1 c. 10 d. Different in each iteration |
b. 1
|
|
15. Typically, the value added to an accumulator variable is ______________
a. 0 b. 1 c. The same for each iteration d. Different in each iteration |
d. Different in each iteration
|
|
16. After an accumulator or counter variable is displayed at the end of a program, it is best to ____
a. Delete the variable form the program b. Reset the variable to 0 c. Subtract one from the variable d. None of the above |
d. None of the above
|
|
17. When you _______, you make sure data items are the correct type and fall within the correct range.
a. Validate data b. Employ offensive programming c. Use object orientation d. Count loop iterations |
a. Validate data
|
|
18. Overriding a user’s entered value by setting it to a predetermined value is known as ____________
a. Forcing b. Accumulation c. Validating d. Pushing |
a. Forcing
|
|
19. To ensure that a user’s entry is the correct data type, frequently you ______________
a. Prompt the user to verify that the type is correct b. Use a method built into the programming language c. Include a statement at the beginning of the program that lists the data types allowed d. All of the above |
b. Use a method built into the programming language
|
|
20. A variable might hold an incorrect value even when it is __________
a. The correct data type b. Within a required range c. A constant coded by the programmer d. All of the above |
d. All of the above
|