How post increment and pre increment are used in GCC Compiler ?

#include<stdio.h>
int main()

{

int x=12;

printf("%d %d",x++,x++);

return 0;

}

The difference comes when you use the post and pre increment in result

for ex

let say i = 5;

int j = i++; // j will contain i, i will be incremented.

now j will be 5 but i will become 6

int j = ++i; // i will be incremented, and j will contain the incremented i.

now j will be 6 and i will also be 6

Hope this helps!!

kunnu is back :smiley:

Btw, more than 1 post increment in a statement in C/C++ = you cant predict the output. Thats what my professor told me when she was telling why these type of Q are not suitable for “Predict Output of following code”.

1 Like

@vijju123 ^-^ what’s up!! ( ͡° ͜ʖ ͡°)

//