+ 2

Does post/pre increment/decrement work the same in all languages and do they even exist in all languages?

x = 5 y = 7 z = x++ + --y I understand that x is updated after evaluating z and y is updated during evaluation in C++, is it the same in all languages? Does x and y retain the updated value just like in C++, especially with pre increment/decrement which I had trouble understanding!

7th Jan 2017, 7:13 AM
Arun Manoharan
Arun Manoharan - avatar
3 ответов
+ 3
Some results depend on the language. {x= ++x + ++x + ++x ;}is the same in cpp and cs however {x += ++x;} gives a different result
7th Jan 2017, 8:16 AM
ifl
ifl - avatar
+ 2
Take a look at my answer here, it might be related to your question: https://www.sololearn.com/Discuss/157809/pre-and-post-increment
7th Jan 2017, 7:17 AM
Bou Hani
Bou Hani - avatar
+ 1
no post/prefer increment/decrement in Python, just do +=1
7th Jan 2017, 4:14 PM
Amaras A
Amaras A - avatar