Programming Concepts

Check your understanding - Repetition

At the end of the pseudocode below, which of the following statements is correct?

Set contents to 0
Set capacity to 1000
Set full to False
Repeat until full is True
    Add 100 to contents
    Stir
    If contents > capacity then set full to True
End repeat

No. The initial value of full is False and so the test condition at the start of the loop isn't satisfied - the loop begins.
No. We are incrementing the value of contents each time through the loop. We then test whether capacity has reached a particular value and set full to true when it does. We would expect the loop test condition (full has the value true) to be satisfied eventually.
Yes. Although this probably isn't the behaviour we want!
← Previous 1 2 3 4 5 6 7 8 9 10 11 12 Next →