--- In [email protected], Asad Abbas <cyberstuden...@...> wrote: > > Why these both statements have same output?? > why i++ and ++i works alike in for loop?? > > > for(int i=0;i<5;i++)
Sequence: i=0 i<5 /* false */ cout << i << endl /* 0 */ i++ /* i=1 */ i<5 /* false */ cout << i << endl /* 1 */ i++ /* i=2 */ : > or > for(int i=0;i<5;++i); Sequence: i=0 i<5 /* false */ cout << i << endl /* 0 */ ++i /* i=1 */ i<5 /* false */ cout << i << endl /* 1 */ ++i /* i=2 */ : Output is the same for both.
