+ 1
What is the difference between (i++) and(++i)??
4 Answers
+ 1
i++ and ++i are unary operators which perform increment operation.
Let us say, i = 0,
i++ => i = i + 1; That is the incrementation takes affect only after the current statement but
++i => i = 1 + i; Here the incrementation takes affect during the execution of that particular statement itself.
+ 12
int i=1;
case 1:
cout<<i++; // outputs 1 because postfix I.e., value will be incremented after
case 2:
cout<<++i; // outputs 2 prefix I.e, incremented before
+ 8
i++ is postfix
++i is prefix