C# Unit 5

  1. A structure that allows repeated execution of a block of statements is a(n) ______.




    D. loop
  2. The body of a while loop can consist of _______.

    A. a single statement
    B. a block of statements within curly
    braces
    C. either a or b
    D. neither a nor b
    C. either a or b
  3. A loop that never ends is called an _________ loop.




    C. infinite
  4. Which of the following is not required of a loop control variable in a correctly working loop?




    D. It is reset to its initial value before the loop ends
  5. A while loop with an empty body contains no _________.




    A. statements
  6. A loop for which you do not know the number of iterations when you write it is a(n) ________.




    C. indefinite loop
  7. What is the major advantage of using a for loop instead of a while loop?




    D. The loop control variable is initialized, tested, and altered all in one place.
  8. A for loop statement must contain _______.




    C. two semicolons
  9. In a for statement, the section before the first semicolon executes ________.




    B. once
  10. The three sections of the for loop are most commonly used for _______ the loop control variable.




    D. initializing, testing, and incrementing
  11. Which loop is most convenient to use if the loop body must always execute at least once?




    C. a do loop
  12. The loop control variable is checked at the bottom of which kind of loop?




    C. a do loop
  13. A for loop is an example of a(n) _______ loop.




    B. pretest
  14. A while loop is an example of a(n) ______ loop.




    A. pretest
  15. When a loop is placed within another loop, the loops are said to be ________.




    B. nested
  16. What does the following code segment display?

    a = 1;
    while (a < 5);
    {
         Write("{0} ", a);
         ++a;
    }

    A. 1234
    B. 1
    C. 4
    D. nothing
    D. nothing
  17. What is the output of the following code segment?

    s=1;
    while (s < 4)
        ++s;
        Write("{0} ", s);




    C. 4
  18. What is the output of the following code segment?

    j = 5;
    while (j > 0)
    {
           Write("{0} ", j);
           j--;
    }




    C. 54321
  19. What does the following code segment display?

    for (f = 0; f < 3; ++f);
        Write("{0} ", f);




    C. 3
  20. What does the following code segment display?

    for (t = 0; t < 3; ++t)
        Write("{0} ", t);




    D. 012
Author
jdavis123
ID
358177
Card Set
C# Unit 5
Description
Updated