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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Ranjit PowarRank #553 · 4.4K reputationPosted Jun 30, 2014, 11:03 PM EDT
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.
VulpesRank #55 · 29.2K reputationPosted Jul 2, 2014, 3:53 PM EDT
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.
Vishal ChaturvediRank #1,011 · 2K reputationPosted Jul 31, 2014, 8:59 AM EDT
Vishal ChaturvediRank #1,011 · 2K reputationPosted Jul 31, 2014, 8:59 AM EDT