it is a silly Q for most of u - i know - but i one of the beginner here, and I can not understand why the output in here are 12 what does this (x--
) do to the resu
x++
is essentially x = x + 1
(the same applies for ++x
). x
is incremented by 1.
x--
is essentially x = x - 1
(the same applies for --x
). x
is decremented by 1.
The difference is that how x++
and ++x
is used in the statement/expression: In ++x
, x
is incremented by 1 first before being used while in x++
, x
is used (before incrementation) first and once it's used, it gets incremented by 1.