"I enter 5 for i, so before loop values are: counter = 1, i = 5, ..."
"Then I enter loop, counter (1) is less than i (5) so loop is executed"
"I assign i*i (5*5) to product, then I add product (25) to total, now it is 25"
"I increment counter, now it 2"
"Next iteration, counter (2) is less than i (5), so loop continues"
"I assign i*i (5*5) to product, then I add product (25) to total, now it is 50"
"I increment counter, now it 3"
"Next iteration, counter (3) is less than i (5), so loop continues"
"I assign i*i (5*5) to product, then I add product (25) to total, now it is 75"
"I increment counter, now it 4"
"Next iteration, counter (4) is less than i (5), so loop continues"
"I assign i*i (5*5) to product, then I add product (25) to total, now it is 100"
"I increment counter, now it 5"
"Next iteration, counter (5) is equalt to i (5), so loop continues"
"I assign i*i (5*5) to product, then I add product (25) to total, now it is 125"
"I increment counter, now it 6"
"Next iteration, counter (6) is greater than i (5), loop terminates"
"Total is 125" |