int a=5; a=++a + ++a; printf("%d",a);
the output is 14..how come?[/QUOTE]
The explanation is only weird for the first time. i.e. ++a + ++a = 14
But if you debug and see the value of a, it will be 7 and after that if u add another ++a to it the answer is 22 and the final value of a is 8 and it increments by 1 for everytime you add ++a
++a + ++a = 14 final value of a=7
++a + ++a + ++a = 22 final value of a=8
++a + ++a + ++a + ++a = 31 final value of a=9
++a + ++a + ++a + ++a + ++a = 41 final value of a=10 and so on....
So lets say you add one ++a to to the first expression and you get the result 22 i.e. 14+8=22 and it continues like this.
The reason for making ++a + ++a = 14 is:
Lets say you want to print the value of a and since there are 2 values of a so the makers of 'C' decided to give both the a's the final value i.e. 7 in this case and added them to give 14.
I hope I am able to give some justification to it.