Tracing the summation program
Find the value at various points. They go in order the way the program processes.
Description |
sum |
sumEachSet |
counter |
numberToAdd |
after line 9 |
0 |
|
x |
x |
after first time line 10 |
0 |
|
1 |
x |
after first time line 12 |
0 |
0 |
1 |
x |
after first time line 13 |
0 |
0 |
1 |
2 |
after first time line 15 |
0 |
2 |
1 |
2 |
after second time line 13 |
0 |
2 |
1 |
3 |
after second time line 15 |
0 |
5 |
1 |
3 |
after third time line 13 |
0 |
5 |
1 |
4 |
after third time line 15 |
0 |
9 |
1 |
4 |
after the number increments on line 13, but before the test (fourth time to line 13) |
0 |
9 |
1 |
5 |
before line 18 |
0 |
9 |
1 |
x |
after line 18 |
9 |
9 |
1 |
x |
after line 10 the second time |
9 |
9 |
2 |
x |
after line 12 the second time |
9 |
0 |
2 |
x |
after line 13 |
9 |
0 |
2 |
3 |
after line 15 |
9 |
3 |
2 |
3 |