+ 2
INCREMENT AND DECREMENT OPERATORS SIMPLIFIED
2 Answers
+ 5
++i means âincrement i IMMEDIATELY,â
while
i++ means âuse the old value of use the old value of i for NOW, but
increment i LATER.â
EXAMPLES=>
int a = 21;
int c ;
*****************************
c = a++;
cout << c c=21
cout << a a=22
*****************************
c = ++a;
cout << c c=23
*****************************
+ 5
well, think of it this way, you get the value of i but you perform the operations in order, so:
x = ++i // increment i; get value of i into x // x and i have the same incremented value
x = i++ // get value of i into x; increment i // x has old i value, i has incremented value