By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,305 Members | 1,588 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,305 IT Pros & Developers. It's quick & easy.

How increment and decrement opertors works in c

P: 40
i want clear explanation of increment and decrement operators in c.

can any body help in solving the following expression
a=10
c=++a + ++a
when i am executing this code ,the answer is c=24
how it is possible?
Jun 3 '07 #1
Share this Question
Share on Google+
3 Replies


P: 3
well ++ hs higher precedence thn + and therefore ur expression becomes
(++a) + (++a)
and the result is 23 ;

(11)+(12)
Jun 3 '07 #2

ilikepython
Expert 100+
P: 844
well ++ hs higher precedence thn + and therefore ur expression becomes
(++a) + (++a)
and the result is 23 ;

(11)+(12)
The result will be undefined. You shouldn't depend on that type of expressions because it could be anything.
Jun 3 '07 #3

AdrianH
Expert 100+
P: 1,251
The result will be undefined. You shouldn't depend on that type of expressions because it could be anything.
See here for more information.


Adrian
Jun 3 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.