118k views
3 votes
What should replace in the following code be if we want this code to repeat until the variable a is greater than 10?

a ← 0 REPEAT UNTIL () { a ← a + 1 }
Option 1: a < 10
Option 2: a <= 10
Option 3: a == 10
Option 4: a > 10

User AConsumer
by
7.5k points

1 Answer

4 votes

Final answer:

The condition that should replace in the code is a <= 10

Step-by-step explanation:

In order for this code to repeat until the variable a is greater than 10, the condition in the REPEAT UNTIL loop should be a <= 10.

The <= operator checks if a is less than or equal to 10. As long as the condition is true, the code inside the loop will continue to execute.

For example, if you start with a = 0, the code will repeat until a becomes 11, at which point the condition will be false and the code will stop repeating.

User Jamida
by
8.3k points