Advertisements
Advertisements
Question
Given: g = ++p + y++ + ++y + p++ + x++;
If p = 2, y = 3, x = 5 then what will be the value of g?
Options
19
18
20
21
MCQ
Advertisements
Solution
19
Explanation:
Given: p = 2, y = 3, x = 5
Expression is interpreted as: g = ++p + y++ + ++y + p++ + x++
Calculation:
++p→ p becomes 3, value = 3y++→ value = 3, then y becomes 4++y→ y becomes 5, value = 5p++→ value = 3, then p becomes 4x++→ value = 5, then x becomes 6
g = 3 + 3 + 5 + 3 + 5 = 19
Therefore, the value of g is 19.
shaalaa.com
Is there an error in this question or solution?
Chapter 1: Revision of Class 9 Syllabus - Exercises [Page 42]
