-1

I am confused about how the printf statement is working in this program? I want to know the way of executing.

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a=5;
    printf("%d %d %d %d\n",a++,++a,++a,1);
    printf("%d",a);
    //printf("Hello world!\n");
    return 0;
}
Jonathan Leffler
  • 698,132
  • 130
  • 858
  • 1,229
selva
  • 97
  • 1
  • 5

1 Answers1

1

This will invoke undefined behavior. Statement

 printf("%d %d %d %d\n",a++,++a,++a,1);  

trying to modify a thrice between two sequence point.

haccks
  • 100,941
  • 24
  • 163
  • 252