int y = 5,x;
x = (++y)+ (++y);
cout<<x;
I would expect the value 13, but I got 14 as the output. any pointers?
what is funny is that the following code gives the value 13.
int y=5;
int x = (++y) + (++y);
cout<<x;
The difference lies in declaration....! so how does it matter?
1
Expert's answer
2012-08-31T08:21:52-0400
In this example you could see error in the compiler implementation. It this case it's an ambiguity and about it was mentioned in most C++ tutorials.
In Java, where this error wasn't made, both parts of this code return the value of 13.
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment