[Solved] How many times does a (for) loop iterate? [closed]


Your for loop is shorthand for the following code:

int i = start;
if (i <= end) {
    /* loop body */
    i += step;
}

To answer your question, it will run ceiling((end - start + 1) / step) times. Walk through the logic on paper to see if you come to the same conclusion.

2

solved How many times does a (for) loop iterate? [closed]