Hi all...
I tried the following code in my Turbo C++ ..
int j=5;
cout<<++j + ++j + j++;
and got the result 20, as expected.
But, when I replaced the code and assigned the same to another variable x, it gives result 21.
ie,
int j=5,x;
x= ++j + ++j + j++;
cout<<x;
gives 21 against the expected value, 20
More interestingly,
if I assign it to same variable j, by replacing x
int j=5;
j=++j + ++j + j++;
cout<<j;
It gives 22 as the output.
Can anyone help please? I am a Computer Science teacher and need urgent help...!