0
Increment and decrement simplified
i dont get how post fix and pre fix works pls explain :(
2 Answers
+ 4
++n increments n, then evaluates it (pre-inctementation).
n++ evaluates n, then increments it (post-incrementation).
They are both equivalent to n=n+1 by themselves, the difference is when they are used in an expression.
int a = 1;
int b = ++a;
cout << a << endl; //prints 2
cout << b << endl; //prints 2
a = 1;
b = a++;
cout << a << endl; //prints 2
cout << b << endl; //prints 1
+ 2
• ++i means “increment i immediately,”
while
i++ means “use the old value of use the old value of i for now, but for now, but
increment i later.”
Hot today
Python — File Handling
0 Votes
Help me solve this (using loop)
3 Votes
What is wrong? Error on test.
1 Votes
Help me wiht python
1 Votes
Question is write a c program to print prime numbers up to n and print the largest number in array.
1 Votes
Help me
0 Votes