76 361
Assignments Done
Successfully Done
In May 2019

Answer to Question #13558 in C++ for Ishaank

Question #13558
int y = 5,x;
x = (++y)+ (++y);
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);
The difference lies in declaration....! so how does it matter?
Expert's answer
In this example you could see error in the compiler implementation. It this case it&#039;s an ambiguity and about it was mentioned in most C++ tutorials.

In Java, where this error wasn&#039;t made, both parts of this code return the value of 13.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions