Answer:
for (i = lo, result = 0; i <= hi; result += i, i++) {}
Step-by-step explanation:
A for loop header has three statements:
- i = 0, result = 0; This statement initializes i and result variables with 0. It is executed only once at the very start of the for loop.
- i <= hi; This statement is executed after the first statement and again after the execution of code in body of the loop.
- result += i, i++ This statement is executed after the execution of code in body of the loop but before the execution of second statement.
Therefore, the following sequence of events will occur:
- The result variable is initialized with 0 at start.
- Then, the condition is checked. If the value of i will be less than or equal to the value of hi, the third statement will be executed.
- The third statement will add the value of i to the value of result and then increase the value of i by 1.
- Then, again the condition in second statement will be checked.
This loop will be executed for as long as the condition remains true.