Can you explain to me | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Can you explain to me

++x + --x what is out of this if x = 6

17th Jun 2019, 10:19 AM
Abdumalik KHamidjonov
Abdumalik KHamidjonov - avatar
3 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.
17th Jun 2019, 3:24 PM
Nootnoot
Nootnoot - avatar
17th Jun 2019, 1:13 PM
Júlia
Júlia - avatar
+ 1
In c++ , what is difference between ++x and x++
17th Jun 2019, 3:22 PM
Abdumalik KHamidjonov
Abdumalik KHamidjonov - avatar