0

I have written this piece of code, but the output of this code is not what i expected. Can anyone explain me how come 15, 4, 6 is the output.

#include <stdio.h>

int main ()
{
    int a = 1, b = 1, d = 1;
    printf("%d, %d, %d", ++a + ++a + a++, a++ + ++b, ++d + d++ + a++);
}
  • 2
    Does this answer your question? [Why are these constructs using pre and post-increment undefined behavior?](https://stackoverflow.com/questions/949433/why-are-these-constructs-using-pre-and-post-increment-undefined-behavior) – UnholySheep Sep 01 '20 at 07:38
  • @UnholySheep Yeah, I understood !!! Thanks – Yash Malaviya Sep 01 '20 at 07:58

0 Answers0