+ 1

x++ & ++x ?

what is mean?

12th Sep 2016, 9:10 PM
Doloop
7 Answers
+ 8
Used alone, they are both equivalent to x = x + 1. When used in an expression, they are either evaluated before the increment (x++) or after it (++x). int a, b; a = 1; b = 1; cout << a++; //prints 1, and a is now 2 cout << ++b; //prints 2, and b is now 2
12th Sep 2016, 9:24 PM
Zen
Zen - avatar
+ 2
int num = 0; while(++num < 6) Console.WriteLine(num); num is initialized at 0. Each loop turn, num is increased by 1, and if it is strictly lower than 6, the value of num is printed. This will print 1 2 3 4 5 (one number per line). Had it be num++ instead of ++num, the values printed would have been 1 2 3 4 5 6.
12th Sep 2016, 9:39 PM
Zen
Zen - avatar
0
false
13th Sep 2016, 6:54 PM
Dmitry Perepelkin
Dmitry Perepelkin - avatar
0
what is false?
13th Sep 2016, 8:35 PM
Doloop
0
Why is not 0 at the beginning when is ++num? Starts from 1 anyway
29th Dec 2016, 4:50 PM
Alessia Giammarino
Alessia Giammarino - avatar
- 1
X++
13th Sep 2016, 1:58 AM
Huong BUi
Huong BUi - avatar
- 2
int num = 0; while(++num < 6) Console.WriteLine(num); i can not understand this program!!!
12th Sep 2016, 9:26 PM
Doloop