0
#include <stdio.h> int main() { int a=1; printf ("%d%d%d",a,++a,a++); return 0; }
Can any one help me to solve doubt ? "Why it give 331 as output ?"
3 Answers
+ 2
it have sequence point issue. Sequence of this types execution is Undefined by standards. So Depends on compiler implementation. Means output is may different in different compilers..
+ 2
It's not a safe to write increment and decrement calculation and try to avoid your code with such types of calculation becz different different compiler will calculate it differently and compiler will confuse here if u will evaluate multiple increment decrement statements expression try same code in cpp and java u will get different output too
+ 1
read this, it's a problem related with the associativity of printf
https://www.geeksforgeeks.org/execution-of-printf-with-plusplus-operators-in-c/