While the run the below program in Turbo C compiler, I am getting the expected output, however, when I run the same program it using gcc compiler in linux, it is giving an unexpected output!int main(){    int i=1;    i=2+2*i++;    printf(i : %d\n,i);    return 0;}Output in Turbo C => i : 5  (This is as expected!)Output in GCC => i : 4 ( Why is the post increment ignored in this case?)Can someone please explain what exactly happens in the compilation process?
How does the post increment operator work in GNU C?
c;operators
As others commented, this i=2+2*i++; is undefined behavior. Please read the wikipage explaining it.See this answer to understand a bit more about UB.Then read Chris Lattner's blog entries What Every Programmer should know about Undefined Behavior.To understand the actual behavior of your buggy C program, you need to dive into implementation details (and you don't want to). If you really want to understand what has happened when using GCC, you might compile your badub.c  program with gcc -fdump-tree-all -O -fverbose-asm -S badub.c  and then lose weeks of your time understanding the (hundreds) of badub.* files that this compilation command produced. Is it worth your time?The lesson is avoid UB at all costTo help more about avoiding UB, recent GCC compilers are sometimes able to emit warnings about it. You should at least compile with gcc -Wall -Wextra -g  to get all warnings and debug info. Learn to use the debugger. Learn about various -fsanitize=  options to recent GCC. Learn and use valgrindBTW, it is the year 2015. Don't use TurboC, which is non-standard compliant, not efficient, not giving good warnings, buggy, proprietary, compiler of the previous century. Use a good free software compiler (like recent GCC or Clang/LLVM. Both can give better code and better warnings -when asked to- than your old crappy TurboC...)