🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Proof Techniques: all 9 questions

Quiz: Proof Techniques · Question 4 of 9

A loop invariant is:

A loop invariant is:

  1. A.A variable that never changes
  2. B.A statement that holds before and after every iteration, used to prove the loop correct
  3. C.An infinite loop
  4. 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 →