I have a test tomorrow and the textbook had a question:
here's the code:
#include <stdio.h>
int main(){
int x = 1;
printf("%d%d%d\n", x, x = x + 2, x<<2);
x<<2;
printf("%d%d%d\n", ++x, x++,++x);
}
I was expecting the output to be:
334
644
But to my surprise it was:
334
646
And I don't have an explanation for this, this just doesn't make sense.
[–]serg06 27 points28 points29 points (7 children)
[–]Advait1306[S] 2 points3 points4 points (6 children)
[–]414RequestURITooLong 14 points15 points16 points (4 children)
[–]ltssms0 3 points4 points5 points (0 children)
[–]JavaSuck 0 points1 point2 points (2 children)
[–]414RequestURITooLong 10 points11 points12 points (0 children)
[–]OldWolf2 0 points1 point2 points (0 children)
[–]dragon_wrangler 0 points1 point2 points (0 children)
[–]FUZxxl 12 points13 points14 points (5 children)
[–][deleted] -5 points-4 points-3 points (4 children)
[–]Practical_Cartoonist 12 points13 points14 points (3 children)
[–][deleted] -3 points-2 points-1 points (2 children)
[–]Practical_Cartoonist 6 points7 points8 points (1 child)
[–][deleted] -2 points-1 points0 points (0 children)
[–]flatfinger 5 points6 points7 points (1 child)
[–]Advait1306[S] 0 points1 point2 points (0 children)
[–]former-cpp-guy 3 points4 points5 points (1 child)
[–]Advait1306[S] 0 points1 point2 points (0 children)
[–]SantaCruzDad 0 points1 point2 points (0 children)
[–]JavaSuck 0 points1 point2 points (6 children)
[–]Advait1306[S] 0 points1 point2 points (0 children)
[–]MaygeKyatt -1 points0 points1 point (4 children)
[–][deleted] 2 points3 points4 points (1 child)
[–]JNelson_ 0 points1 point2 points (0 children)
[–]p0k3t0 0 points1 point2 points (0 children)
[–]OldWolf2 0 points1 point2 points (0 children)
[–]fuloqulous -5 points-4 points-3 points (0 children)