Which type of loop should be used when the number of repetitions is not known in advance?
A condition controlled loop
A program keeps asking for a password while the password entered is not equal to 'rE5Bh9dP'. The user enters the correct password on the first attempt. What happens?
The loop body does not run at all
What is an infinite loop?
A loop whose condition never becomes false
In a while loop, which statement is true about the code the loop repeats?
It must eventually change the value used in the condition
What does a while loop do when its condition is tested and found to be false?
It ends the loop and continues with the code after it
A program uses a while loop to let a user enter numbers until they enter zero. Which statement is true?
The number of iterations depends on user input
A while loop starts with count set to 1 and adds 1 to count each time it repeats. Which condition makes the loop count from 1 up to and including 10?
while count <= 10
What is meant by iteration?
One complete pass through the statements in a loop
What is meant by a condition controlled loop?
A loop that repeats while a condition is true, so the number of repetitions can vary
Which term describes repeating a block of code while a condition remains true?
While loop
What is meant by a variable number of iterations?
The loop repeats a number of times that depends on the condition
A while loop repeats while score < 10. Nothing inside the loop ever changes the value of score. What happens when the program runs?
The loop never ends because the condition stays true
A program must keep asking the user to type a password until the correct password 'jd8UpP2+d' is entered. Which condition repeats the loop while the password entered is wrong?
while password != 'jd8UpP2+d'
A while loop starts with count set to 1 and repeats while count < 4. The body of the loop prints count and then adds 1 to count. How many times does the body run?
Three times
A while loop keeps reading values until its condition becomes false. Why is the condition tested again at the start of every repetition?
Because the value it tests may have changed inside the loop body
We use cookies to enhance your experience. You can manage your preferences or learn more in our Cookie Policy.