1
   #include<stdio.h>
   int main()
   {

     int a=5,b;
     b=a++ + ++a ;
     printf("%d",b);
     return 0;
   }

//now give a =5 when you scan for a instead of assigining a=5.

ramesh
  • 11
  • 1
  • 4
    `b=a++ + ++a ;`...perfect example of well-defined `undefined behaviour`. – Sourav Ghosh Dec 12 '14 at 07:42
  • I haven't got your answer can you tell me the reason for my question. just check the above code in codeblocks you will get different answer .when a is assigned a value and when a get the same value using scanf – ramesh Dec 12 '14 at 07:52
  • there is no logic that can define something called undefined behavior. – Sourav Ghosh Dec 13 '14 at 13:38
  • But I haven't got my answer . How can a same compiler can give two different answer when you are performing same task with same data. – ramesh Dec 14 '14 at 02:20

0 Answers0