Post and Pre Increment

When ++ is set at the beginning of a variable it is called prefix increment. i.e: ++x
When ++ is set at the end of a variable it is called postfix increment. i.e: x++

x++ and ++x are equivalent to x=x+1 but what is the difference between x++ and ++x?
x++ will increment the value of x by one but return the previous value.

OUTPUT

x++ = 65

++x will increment the value of x by one and return the update value.

OUTPUT

++x = 66


Next Previous