1.
The value 6 is copied into the parameter n and control moves into sumTo.
2.
The condition is tested with k equal to 7, it is false, and execution leaves the loop.
3.
The return statement sends the value of total, which is 21, back to the call site.
4.
The caller evaluates the argument expression 2 * 3 to get 6.
5.
Control resumes in main, which stores 21 in result and prints it.
6.
The condition k <= n is tested before each pass; while it is true, k is added to total and k is incremented.
7.
The local variables total and k are initialized to 0 and 1.