include <stdio.h> int main() { int b=7,a; a=b++ + ++b+b++ ; printf ("%d\n",a); return 0; } | Sololearn: Learn to code for FREE!


include <stdio.h> int main() { int b=7,a; a=b++ + ++b+b++ ; printf ("%d\n",a); return 0; }

Explanation please

10/22/2021 5:19:33 AM

Palleni Sasidhar

6 Answers

New Answer


The statement a=b++ + ++b + b++ ; is garbage code that will produce unpredictable results. Using multiple pre/post increment/decrement operators on the same variable in the same statement will create sequence point errors. It is undefined behaviour. Just don't do it.


#include <stdio.h> int main() { int b = 7, a; a = b++; printf("%d\n",a); a += ++b; printf("%d\n",a); a += b++; printf("%d\n", a); return 0; }


a=b++ + ++b+b++; 1)a=((b++)+(++b))+(b++); 2)++b = 8 3)b++ = 8 4)b++ = 9 5)a=8+8+9 6)a=25 b=10


I am unable to explain via chat therefore i have shared code explaination, if you know use of ++b or b++ then you will understand it. if you dont know about it then do some research


Please always tag the language you're asking about.


It produces garbage value at the result due to the variable A value is not defined. Just check this link for your understanding about the unary operators in c.