8.1.6 Iteration (WHILE … DO … ENDWHILE) Flashcards

1
Q

What is a WHILE … DO … ENDWHILE loop

A
  • It is a pre-condition-controlled loop.
    • The condition is checked at the start of the loop.
    • The code inside the loop may not execute.
    • The loop is executed when the condition becomes false
      Used when you do not know how many time to iterate.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

WHILE … DO … ENDWHILE loop example

A

STRING guess = “”

WHILE guess <> “Turing” DO
OUTPUT “What is my name? “
INPUT guess
ENDWHILE

OUTPUT “Alan Turing actually”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly