+ 3

What is a difference between ++x and x++?

19th Nov 2016, 11:02 PM
Денис Данов
Денис Данов - avatar
7 Answers
+ 8
a = x++ means assign the value of x to a, then increment x. a = ++x means increment x, then assign the incremented value to a
19th Nov 2016, 11:05 PM
Marcell Juhasz
+ 5
Like, x=2; cout<<++x<<newl; cout<<x; \\print 3 and 3 Now: x=2; cout<<x++; cout<<x; //print 2 and 3
20th Nov 2016, 1:19 AM
Matheus De Mello Vieira
Matheus De Mello Vieira - avatar
+ 2
++x means at that moment the value +1 whereas x++ means when we use the value next time it is increased by 1
21st Nov 2016, 5:46 PM
Joel Joboy Joseph
Joel Joboy Joseph - avatar
+ 1
++x is prefix increment operation which follows the "change then use" rule which means that ++x will first increment the value of x by 1 and then use it whereas x++ is postfix increment operation which follows the "use then change rule" which means that the value of variable 'x' will be first used and then incremented
21st Nov 2016, 9:05 AM
Chitransh Vishwakarma
Chitransh Vishwakarma - avatar
0
preincrement and posrimcrement
22nd Nov 2016, 1:51 PM
neelesh
neelesh - avatar
0
one is increment operator and the other one is decrement operator.
29th Nov 2016, 6:25 AM
Riya
Riya - avatar
- 2
preincrement and postincrement
21st Nov 2016, 5:34 PM
abdelpeer
abdelpeer - avatar