August 10th, 1999, 07:27 PM
I just have some questions about the prefix and postfix versions of the ++ and -- statement. Correct me if I'm wrong but when the postfix ++ or -- statement it used it increments (or decrements) the variable it's connected to but returns the value of the variable directly before the ++ or -- statement was called so then
int i=5;
a = i++
would make a = 5 and i = 6;
When the prefix versions are used it increments or decrements depending on which is called the connected variable. But this time it returns the new value so if the prefix versioin was used above a would = 6. Now here's my question I have the following code in a program
int i=5;
c = (i++) + (i++);
and it makes c = 10, not 11. Why is that?
int i=5;
a = i++
would make a = 5 and i = 6;
When the prefix versions are used it increments or decrements depending on which is called the connected variable. But this time it returns the new value so if the prefix versioin was used above a would = 6. Now here's my question I have the following code in a program
int i=5;
c = (i++) + (i++);
and it makes c = 10, not 11. Why is that?