Simple but many of the people aren't aware of it.
Difference between i++ and ++i
Most of us struggle with these two while finding the output of C/C++ programs.
i++ works follows:
First the value of i will be used and the value will be incremented
i=1;j=i++;
ans:i=2,j=1.
In case of ++i:
The value of i will be increased first then it'll be used.
i=1;
j=++i;
ans:i=2,j=2.
Hope all the above information will be helpful for the beginners as well as for the people who have struggled with the pre-increment and post-increment process in C.


Comments