0
How to use the ++ line in both prefix and postfix method?
"int x=3; int y=x++;" and "int x=3; int y=++x;" What are the difference in the value of x?
1 Respuesta
+ 1
The first version says set y equal to x and then add 1 to x, so here y is 3 and x is 4.
The second version says add 1 to x and then set y equal to x, so here x is 4 and y is 4.
In both cases x is the same, you are starting at 3 and adding 1 to it, the difference is the value held in y.