1.
The structure that allows you to write one set of instructions that operates on multiple, separate sets of data is the _____.
Correct Answer
A. Loop
Explanation
A loop is a programming structure that allows you to repeat a set of instructions multiple times. It is used when you want to perform the same operations on different sets of data. By using a loop, you can write a single set of instructions and apply it to multiple sets of data, making your code more efficient and concise. Therefore, a loop is the correct answer for this question.
2.
Every structured loop _____.
Correct Answer
A. Has one entry point
Explanation
Every structured loop has one entry point. This means that there is only one point in the loop where the program flow enters the loop and starts executing the loop statements. Once the loop is entered, the program continues to execute the loop statements until a certain condition is met, causing the program flow to exit the loop. Therefore, a structured loop always has a single entry point.
3.
Which of the following is not a step that must occur with every correctly working loop?
Correct Answer
A. Set the loop control value equal to a sentinel during each iteration.
Explanation
Setting the loop control value equal to a sentinel during each iteration is not a step that must occur with every correctly working loop. A sentinel value is typically used to indicate the end of a loop, but it is not necessary for every loop. The other three steps - initializing a loop control variable before the loop starts, comparing the loop control value to a sentinel during each iteration, and altering the loop control variable during each iteration - are commonly required for loops to function correctly.
4.
The statements executed within a loop are known collectively as the _____.
Correct Answer
A. Loop body
Explanation
The loop body refers to the statements that are executed within a loop. It is the block of code that is repeatedly executed until the loop condition becomes false. The loop body contains the instructions or actions that need to be performed repeatedly, allowing for repetitive tasks or computations to be carried out efficiently.
5.
A counter keeps track of _____.
Correct Answer
A. The number of times an event has occurred
Explanation
A counter keeps track of the number of times an event has occurred. This means that it is used to count and keep a record of how many times a specific event or action has happened. Counters are commonly used in programming and electronics to monitor and control various processes and events. They are useful for tasks such as counting the number of button presses, tracking the frequency of events, or measuring the occurrences of certain actions.
6.
Adding 1 to a variable is also called _____ it.
Correct Answer
A. Incrementing
Explanation
Incrementing means increasing the value of a variable by a specific amount, usually by adding 1. In this context, adding 1 to a variable is referred to as incrementing it. This operation is commonly used in programming to update the value of a variable in a loop or to count occurrences.
7.
Which of the following is an indefinite loop?
Correct Answer
A. A loop that follows a prompt that asks a user how many repetitions to make and uses that value to control the loop
Explanation
An indefinite loop is a loop that does not have a predetermined number of iterations. It continues to execute until a certain condition is met. In this case, the loop that follows a prompt asking the user how many repetitions to make and uses that value to control the loop is an indefinite loop because the number of repetitions is determined by the user's input, not a fixed number. Therefore, it can execute any number of times depending on the user's input.
8.
Which of the following is a definite loop?
Correct Answer
A. A loop that executes 1000 times
Explanation
A definite loop is a loop that has a predetermined number of iterations. In this case, a loop that executes 1000 times is a definite loop because it will always run exactly 1000 times, regardless of any external conditions or user input. On the other hand, a loop that executes as long as a user continues to enter valid data is an indefinite loop because it relies on user input and can potentially run indefinitely until the user stops entering valid data. Therefore, the correct answer is a loop that executes 1000 times.
9.
When you decrement a variable, you _____.
Correct Answer
A. Subtract 1 from it
Explanation
When you decrement a variable, you subtract 1 from it. This means that the value of the variable is decreased by 1. It is a common operation used in programming to decrease the value of a variable by a certain amount.
10.
When two loops are nested, the loop that is contained by the other is the _____ loop.
Correct Answer
A. Inner
Explanation
When two loops are nested, the loop that is contained by the other is referred to as the inner loop. The inner loop executes its set of instructions repeatedly within each iteration of the outer loop. This allows for more complex and precise control flow, as the inner loop can perform a specific task multiple times before moving on to the next iteration of the outer loop.
11.
When loops are nested, _____.
Correct Answer
A. None of the above
Explanation
When loops are nested, they do not necessarily have to meet any of the conditions mentioned in the answer options. The behavior of nested loops can vary depending on the specific programming language and the logic implemented within the loops. Therefore, none of the above options accurately describe the behavior of nested loops in general.
12.
The chief advantage to using a for loop is _____.
Correct Answer
A. Its syntax is concise
Explanation
The correct answer is that the chief advantage to using a for loop is that its syntax is concise. This means that the code written using a for loop is shorter and easier to read compared to other loop structures. The for loop allows initializing a variable, setting a condition, and incrementing the variable all in one line, making it more efficient and convenient for iterating over a specific range of values.
13.
A report that lists only totals, with no details about individual records, is a(n) _____ report.
Correct Answer
A. Summary
Explanation
A report that lists only totals, with no details about individual records, is referred to as a summary report. This type of report provides an overview or summary of the data, presenting aggregated information such as totals, averages, or percentages without including the specific details of each individual record. It condenses the information and provides a high-level view of the data, making it easier to analyze and understand the overall trends or patterns.
14.
Typically, the value added to a counter variable is _____.
Correct Answer
A. 1
Explanation
The value added to a counter variable is typically 1.
15.
Typically, the value added to an accumulator variable is _____.
Correct Answer
A. Different in each iteration
Explanation
The value added to an accumulator variable is typically different in each iteration. In a loop or iteration, the accumulator variable is used to store and accumulate values. The value added to the accumulator variable can vary depending on the specific logic or calculation being performed within each iteration. This allows the accumulator variable to keep track of a changing or accumulating value throughout the loop.
16.
After an accumulator or counter variable is displayed at the end of a program, it is best to _____.
Correct Answer
A. None of the above
Explanation
After an accumulator or counter variable is displayed at the end of a program, it is best to leave the variable as it is without making any changes. This is because the variable may be needed for future calculations or reference, and altering it by subtracting 1, resetting it to 0, or deleting it from the program could lead to errors or incorrect results in subsequent operations.
17.
When you _____, you make sure data items are the correct type and fall within the correct range.
Correct Answer
A. Validate data
Explanation
The correct answer is "validate data" because when you validate data, you ensure that the data items are of the correct type and within the appropriate range. This process helps to ensure data integrity and accuracy, preventing errors and issues that may arise from using incorrect or out-of-range data. It is an important step in data validation and verification processes to ensure the reliability and validity of the data being used.
18.
Overriding a user’s entered value by setting it to a predetermined value is known as ______.
Correct Answer
A. Forcing
Explanation
Overriding a user's entered value by setting it to a predetermined value is commonly referred to as "forcing." This term implies that the user's input is disregarded or overridden in favor of the predetermined value.
19.
To ensure that a user’s entry is the correct data type, frequently you ______.
Correct Answer
A. Use a method built into the programming language
Explanation
To ensure that a user's entry is the correct data type, it is common practice to use a method built into the programming language. These methods are specifically designed to validate and check the data type of user input, ensuring that it matches the expected type. By utilizing these built-in methods, programmers can easily verify and handle different data types without the need for additional code or manual checks. This approach helps to improve the accuracy and reliability of the program by preventing errors and unexpected behaviors caused by incorrect data types.
20.
Variables might hold incorrect values even when they are _____.
Correct Answer
A. All of the above
Explanation
Variables might hold incorrect values even when they are coded by the programmer rather than input by a user, within a required range, and of the correct data type. This is because the programmer may make mistakes while coding, such as assigning the wrong value to a variable. Additionally, even if the value is within the required range, it may still be incorrect for the specific context or calculation. Finally, the variable may have the correct data type, but the actual value assigned to it may still be incorrect. Therefore, all of the above factors can contribute to variables holding incorrect values.