Jan-15-2019, 06:33 AM
line 5: everything below x = 400 will be executed until x >= 852
on 1st iteration 1 = 0 and x = 400, so while loop is executed
6 of course prints value of x (400)
line 7 says if i > 0 execute line 8 otherwise execute line 10 -- 1st iteration is 0, so else gets executed
line 10: x = x + 67 -- so x becomes 467
line 11 increments i by 1 -- i becomes 1
--- back to line 5 -- x is 467 so still less than 852
line 6 print x = 467
line 7 this time i is greater than 0, so execute line 8
line 8 can be broken down:
x = 467 = ((i + 4) * 67) = x + (4 * 67) = 467 + 268 = 755
x = 755 + (i * 49) = 755 + (1 * 49) = 755 + 49 = 804
repeat one more cycle (x < 852) for final results
on 1st iteration 1 = 0 and x = 400, so while loop is executed
6 of course prints value of x (400)
line 7 says if i > 0 execute line 8 otherwise execute line 10 -- 1st iteration is 0, so else gets executed
line 10: x = x + 67 -- so x becomes 467
line 11 increments i by 1 -- i becomes 1
--- back to line 5 -- x is 467 so still less than 852
line 6 print x = 467
line 7 this time i is greater than 0, so execute line 8
line 8 can be broken down:
x = 467 = ((i + 4) * 67) = x + (4 * 67) = 467 + 268 = 755
x = 755 + (i * 49) = 755 + (1 * 49) = 755 + 49 = 804
repeat one more cycle (x < 852) for final results