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
Question 2. 2. (TCO 5) In a ForNext loop, the control structure performs which of the following? (Points : 3) | Counter initialization Counter testing Counter adjustment All of the above |
Question 3. 3. (TCO 5) When should a programmer select a Posttest loop? (Points : 3) | When you know exactly how many times you need to execute the loop body When the loop body needs to be executed at least one time When you want to ensure that the loop might never be executed You should never select a Posttest loop; Pretest loops are always preferred. |
Question 4. 4. (TCO 10) Code walk-throughs are used to improve code. What action(s) are taken during a walk-through? (Points : 3) | Correcting syntax errors Review of the code against another programmers code Identification of positive and negative elements of the code Criticize the programmer for errors or inconsistencies All of the above |
Question 5. 5. (TCO 5) Using floating-point values for counters in ForNext loops is _____. (Points : 3) | traditionally the way ForNext loops are designed a good idea for increasing precision a poor programming practice and should be avoided neither a good idea nor a bad idea |
Question 6. 6. (TCO 5) A loop that contains a separate inner loop in its execution code is called an _____. (Points : 3) | outer loop inner loop infinite loop None of the above |
Question 7. 7. (TCO 5) A loop that never stops executing is called _____. (Points : 3) | a nested loop an infinite loop a Pretest loop a Posttest loop |
Question 8. 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 |
Question 9. 9. (TCO 5) How many times will DOG be displayed when the following lines are executed? For counter As Integer = 13 To -3 Step -6 System.Console.WriteLine("DOG") Next (Points : 3) | Two Three Four Five None of the above |
Question 10. 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 |
Question 11. 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) |