← Quiz: Proof Techniques: all 9 questions
Quiz: Proof Techniques · Question 4 of 9
A loop invariant is:
A loop invariant is:
- A.A variable that never changes
- B.A statement that holds before and after every iteration, used to prove the loop correct
- C.An infinite loop
- D.A compiler optimisation
Answer & explanation
Correct answer: A statement that holds before and after every iteration, used to prove the loop correct
It is induction applied to loops: initialisation, maintenance, termination.
Can you get the rest right without peeking?
Take the timed Quiz: Proof Techniques quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →