How to solve a+++++a type questions | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to solve a+++++a type questions

I couldn't able to solve these type questions and found some difficult

4th Apr 2020, 1:05 PM
Gajjala Venkata Sai Sri Harsha Hanumantha Rao
Gajjala Venkata Sai Sri Harsha Hanumantha Rao - avatar
2 Answers
+ 2
Let us consider a=5 a++ means value of a is increased by 1 but not displayed ( i.e. if you print 'a++', your output will be 5 not 6. In case of ++a your output will be 6. Came to your question: (a++) + (++a) i) output of a++ is 5 (but actual value=6 because it is increased by 1) ii) now actual value of 'a' is 6, here a is increased by 1 again making the value 7 (++a) Your ans= (a++) + (++a) =5 + 7 = 12. Hope it helps.
4th Apr 2020, 1:38 PM
Kashyap Kumar
Kashyap Kumar - avatar
0
Gajjala Venkata Sai Sri Harsha Hanumantha Rao the answer to this question will vary depending on the programming language used. This expression will give an undefined result because the answer will be compiler dependent for programming languages like C and C++. https://code.sololearn.com/cxi2Qy3mUGG7/?ref=app
4th Apr 2020, 1:52 PM
Avinesh
Avinesh - avatar