P.S: This is just a study guide. The questions may not appear exactly like this.
1. (TCO 5) Which of the following is a component of a repetition structure? (Points : 3)
An initial assignment of a counter or stopping variable
A condition that, when met, will stop the loop
An increment/decrement of the counter
All of the above
2. (TCO 5) When should a programmer select a For…Next loop for a program? (Points : 3)
When the programmer knows the exact number of times the loop will be executed
When the programmer knows the loop must be executed at least once
When the programmer is not sure how many times the loop will be executed
There is no reason to select a For… Next loop. Any loop can be used any time.
3. (TCO 5) The instructions in a Pretest loop will always be processed _____ or more times. (Points : 3)
three
two
one
zero
4. (TCO 10) Code walk-throughs are used to improve code. What action is NOT taken during a walk-through? (Points : 3)
Correcting syntax errors
Review of the parameters and data structures used
Identification of positive and negative elements of the code
Evaluation of the details of the code
5. (TCO 5) Floating-point variables, such as Double, should not be used _____. (Points : 3)
as counters that control loop execution
to perform mathematical calculations inside a loop
as approximate representations of decimal numbers
for applications when precision is required
6. (TCO 5) A loop that resides inside another loop is called an _____. (Points : 3)
outer loop
inner loop
infinite loop
None of the above
7. (TCO 5) An infinite loop occurs when _____. (Points : 3)
a loop counter does not converge on an exit condition
a loop counter does converge on an exit condition
one loop is nested inside another loop
three or more levels of nested loops exist
8. (TCO 5) Given the following partial program, how many times will the inner loop body (System.Console.WriteLine((outer*inner).ToString(“N0”))) be executed?
Dim inner, outer As Integer
For outer = 0 To 6
For inner = 1 To 4
System.Console.WriteLine((outer*inner).ToString(“N0”))
Next
Next (Points : 3)
10
11
24
28
None of the above
9. (TCO 5) How many times will HELLO be displayed when the following lines are executed?
For counter As Integer = 20 To -2 Step -4
System.Console.WriteLine(“HELLO”)
Next (Points : 3)
Two
Four
Six
Eight
None of the above
10. (TCO 5) How many times will the word HI be displayed when the following lines are executed?
Dim c As Integer = 12
Do
System.Console.WriteLine(“HI”)
c = c + 3
Loop Until (c >= 30) (Points : 3)
Four
Six
Nine
10
11. (TCO 5) Assume that counter and exitCondition are integer variables. Describe precisely the output produced by the following segment for the test inputs 8 and 3.
Dim counter As Integer
Dim exitCondition As Integer = 5
counter = CInt(System.Console.ReadLine())
Do While (counter < exitCondition)
System.Console.WriteLine(counter.ToString("N0"))
counter = counter + 1
Loop (Points : 5)