int a=5;
a=++a + ++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.

WaltP commented: Completely wrong and misleading! -4

The 'scanf' buffer gets full after you enter the name. So either flush it or use 'gets' function. All the best.

WaltP commented: Use gets() on;y if you want to write a program that is broken before you even compile it. Search to see why... -4

The following link will answer all your questions [URL="

silvercats commented: I am already reading a TCP/IP book and that doesn't have answers for these questions and I don't want to read another book for these small answers -1

[QUOTE=Narue;1736788]Did you not read the thread before posting your incorrect answer?[/QUOTE]

I compiled it on Dev C++ and that is exactly the output i got. Please tell me what is wrong about it?

you should get 7 6 6
and its simply bcoz printf has the precedence from Right to Left.

You can try using "unsigned" but you will not be able to use negative numbers as well or you can give the numbers a range and anything outside the range will produce an error

WaltP commented: Worthless advice -4