Post-increment and pre-increment within a ‘for’ loop produce same output [duplicate]

The following for loops produce identical results even though one uses post increment and the other pre-increment.

Here is the code:

for(i=0; i<5; i++) {
    printf("%d", i);
}

for(i=0; i<5; ++i) {
    printf("%d", i);
}

I get the same output for both ‘for’ loops. Am I missing something?

12 Answers
12

Leave a Comment