Question

1.
2.
3.
4.
Answer (Detailed Solution Below)

Option 2 : 14 / 14

Advertisement

Detailed Solution

सही उत्तर 14 / 14 है।

Key Points
Helpful?
PrepSnapprepsnap.in • Part -A

Question:

The table below walks through evaluating `int r = 10 + 2 * 3 - 8 / 4 % 3;` in Java/C++ step by step. Which value belongs in place of (?) in the final row? / नीचे दी गई तालिका Java/C++ में `int r = 10 + 2 * 3 - 8 / 4 % 3;` के मूल्यांकन को चरण-दर-चरण दर्शाती है। अंतिम पंक्ति में (?) के स्थान पर कौन-सा मान आएगा?

1.
12 / 12
2.
14 / 14
3.
16 / 16
4.
18 / 18

Correct Answer: 14 / 14

Multiplicative operators bind tightest: 2*3=6, 8/4=2, then 2%3=2, leaving 10+6-2=14. The trap is computing left to right as ((10+2)*3-8)/4%3, or mis-ordering % with / — both have the same precedence and associate left to right. / गुणात्मक operator सबसे कसकर बँधते हैं: 2*3=6, 8/4=2, फिर 2%3=2, शेष 10+6-2=14। जाल बाएँ-से-दाएँ ((10+2)*3-8)/4%3 गिनना है, या % को / से गलत क्रम देना है — दोनों की precedence समान है और ये बाएँ-से-दाएँ associate होते हैं।

Downloaded from PrepSnap (prepsnap.in)