Flowcharts, Pseudocode and Python
Quiz 8
Repetition Structures


Answer questions 1, 2 and 3 for the pseudocode below:

count = 1
While count <= 3 Do
    print count
    count = count + 1
EndWhile
print count

  1. What will be printed by the "print count" statement which comes after the EndWhile statement:

    3
    4
    5
    2

  2. How many times will the "print count" statement be executed inside the loop:

    3
    4
    5
    2

  3. How many times will the "While count <= 3" statement be executed:

    3
    4
    5
    2

    Answer questions 4 and 5 for the pseudocode below:

    For (index = 1, index < 14, index = index + 3)
        print index
    endFor
    

  4. How many times will the "print index" statement be executed:

    5
    4
    6
    3

  5. What will be the value of index for the second iteration:

    5
    4
    6
    3

  6. One wants to print even numbers between 14 and 20. Which for loop will accomplish this:

    For (i = 12, i < 20, i = i + 2)
    For (i = 14, i < 20, i = i + 2)
    For (i = 14, i <= 20, i = i + 2)
    For (i = 14, i < 23, i = i + 2)

  7. What will be printed for the following code?

    product = 1
    For (i = 1, i <=3, i = i + 1
        product = product * i
    endFor
    print product
    

    3
    5
    6
    4

  8. What values of sales will stop the while loop shown below:

    While (sales > 0)
        print sales
        get sales
    endWhile
    

    0
    All numbers less than 0
    All numbers less than or equal to 0
    47

  9. Is there anything wrong with the loop shown below assuming sales to be 10000:

    While (sales > 0)
        print sales
    endWhile
    

    Nothing is wrong
    Loop will run forever

  10. What will be printed for the code shown below:

    sum = 0
    For (i = 1, i <= 4, i = i + 1)
        sum = sum + 1
    endFor
    print sum
    

    15
    5
    6
    10