Output Question Doubt ??
The output of the following program is 5,3,4,4
Should it not be 5,3,5,3??
1 2 3 4 5 6 7 8 9 10
|
#include<iostream.h>
void main()
{
int x=5,y=5;
cout<<x--;
cout<<",";
cout<<--x;
cout<<",";
cout<<y--<<","<<--y;
}
| |
The C++ standard does not define the outcome of line 9 because you are not allowed to manipulate a value twice in the same expression like that.
so how is the output for line 9 decided??
Prefix has higher precedence than postfix / suffix.
alright thanks topic closed
This has nothing to do with precedence.
Topic archived. No new replies allowed.