if we execute this expression in turbo c,using c language
a=7
b=(++a)*(++a)
the output will come is 81,that is wrong it must be 72,why ?????????
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Vishal ChaturvediPosted Jul 31, 2014, 12:59 PM
Vishal ChaturvediPosted Jul 31, 2014, 12:59 PM
VulpesPosted Jul 2, 2014, 7:53 PM
Basically, the operands are determined before the result of the multiplication operator is calculated. Consequently, 'a' gets incremented twice on both sides of the * operator.
Ranjit PowarPosted Jul 1, 2014, 3:03 AM
1. As a=7, it solve first bracket and increment the value of a to 8.
2. In second step the second bracket is solved and again it increment value of a to 9.
3. Then multiplication operation takes place as 9*9=81.
4. And then 9 is assigned to b.