+ 1
x++ & ++x ?
what is mean?
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
+ 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.
0
false
0
what is false?
0
Why is not 0 at the beginning when is ++num? Starts from 1 anyway
- 1
X++
- 2
int num = 0;
while(++num < 6)
Console.WriteLine(num);
i can not understand this program!!!