# Pre and post increments in C [closed]

void main()
{
int a = 1;
a = ++a + ++a + ++a;
printf("%d",a);
}

the above program gives the output 12.
What I have understood is that the variable 'a' is incremented thrice before it is cosidered for evaluation of the expression.

What I have'nt understood is why all the three increments are performed before any of them is evaluated in the expression.

Can anybody explain me with some simple equivalent low-level code about how the evaluatoin is done ?

-
I think this question is more appropriate on stackoverflow, as it concerns real-world programming. I also think that the behaviour here is undefined, ++a "returns the value of a after incrementation" but the incrementation doesn't have to happen (but is allowed to) until the next sequence point. Check the C standard for details. – adrianN Feb 5 at 17:58
@RaviTeja When you're blocked from posting questions on Stack Overflow, there no point in trying to bypass the block by asking on another site. Even if we wanted to, we cannot migrate the question to a site where you are blocked from asking. Read the link in the message that tells you that you are blocked for advice. – Gilles Feb 5 at 18:38
@RaviTeja See this answer on Stack Overflow: stackoverflow.com/a/4177063/71074 – Robert S. Barnes Feb 6 at 20:41
thanks... i was looking for those details. – Ravi Teja Feb 7 at 9:27

## closed as off topic by Gilles♦Feb 5 at 18:37

Questions on Computer Science Stack Exchange are expected to relate to computer science within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

That code is completely illegal, as it changes a several times between sequence points. Technically, that is undefined behaviour, the compiler can do whatever it pleases (and old gcc launched nethack in such cases).