cout and function call....strange

This is a discussion on cout and function call....strange within the C++ Programming forums, part of the General Programming Boards category; Ok we did a program in class thats pretty self explanatory. I wrote it two ways, our main focus is ...

That output is correct according to the program. Now my question is this: Why does having it in one cout make it give correct value for "value" on the first part then the wrong number ont he second part?? According to logical program flow, should it not output two 100's even tho its in one cout because its been changed??? I know this is because of how i write the cout, but i don't know why. Heres the full program with the cout line that is working wrong being used:

Its almost as tho its flowing into the cout, calling the function, returning the right number, backing up before the cout, skipping the call,a nd outputting the original value. It makes no sense, the teacher didn't have an explanation either.

eib i thought the same thing, but i mean its AFTER the value change in the cout, so if the first output of the value is correct, then the second should be. If i am correct the reference parameter "&" would give the value it returns to the variable it got the original value from, as it does, gives 100 to value.