I had been going over a few tricky and unusual behaviour that C code snippets produce, and I came across one that resulted an unusual output.
int main()
{
int i=3;
printf("%d%d%d", i, ++i, i++);
return 0;
}
I thought this would have resulted in 344, but the output was 553.
I searched for the reason and apparently it's because of undefined behaviour of certain statements, particularly if there are multiple changes done to the same variable in a single statement.
However, how do you predict what the output would be? And how is 553 computed and justified as the answer to the above code snippet?
There might be an answer somewhere on SO, but I didn't know what to search for exactly. Thanks.