INCREMENT AND DECREMENT | SoloLearn: Learn to code for FREE!

0

INCREMENT AND DECREMENT

Need help explaining how it works. Prefix and postfix.

5/19/2019 7:06:48 AM

Aboubakare Sidiki Kakoro

2 Answers

New Answer

+1

Prefix: ++x/--x Postfix: x++/x-- If you use the prefix in an assignment, like y = ++x; then x will be increased by 1, and then it will be assigned to y Example: x = 5; y = ++x; //y AND x equals 6 Postfix: y = x++; x will be assigned to y, then increased by 1 Example: x = 5; y = x++; //y equals 5 and x equals 6 This was explained in every lesson about incrementing and decrementing, i don't understand why did you need to ask this question in the first place

0

I just did not understand it fully, because it pretty much does the same thing. Just weirdly explained