+ 2
Can you explain to me
++x + --x what is out of this if x = 6
5 Answers
+ 4
Hello, that is my favorite operator so let me discuss this:
++x or --x // is Prefix Increment/Decrement
x++ or x-- // is Postfix Increment/Decrement
So:
On Prefix Increment, the interpreter evaluates the operation before the statement.
x = 3
++x // 4
y = ++x + 2 // 6
On postfix - Its almost the same in the Prefix operator, but only in one thing: the operation will only happen after the statement is evaluated.
x = 3
x++ // 4
y = x++ + 2 // 3 + 2 = 5 and now x = 4
Hope this is helpful. This is how JavaScript do Increments and Decrements and I think its the same in the other language.
+ 2
https://code.sololearn.com/c0rPE5C6YriW/?ref=app
That could help you
+ 1
In c++ , what is difference between ++x and x++