Does the Invariant Hold?
// Store 1 + 2 + 3 + 4 in s
s= 0; i= 1;
// General picture: s= 0 + 1 + 2 + � + i-1.
while (i != 5)
{s= s + i; i= i+1;}
Initialization?
Each iteration?
Previous slide
Next slide
Back to first slide
View graphic version