Advertisements
Advertisements
प्रश्न
Evaluate the following expression as per Java priority & associativity.
1234 % 100 – 1234/100
मूल्यांकन
Advertisements
उत्तर
Priority (Precedence): Modulo (%) and division (/) have higher precedence than subtraction (–), so they are evaluated first.
Associativity: Since % and / share equal precedence, they evaluate from left to right.
- 1234 % 100: Leaves a remainder of 34.
- 1234 / 100: Performs integer division, discarding the remainder, which gives 12.
- 34 – 12: Subtraction completes, giving a final answer of 22.
shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 1: Revision of Class 9 Syllabus - Exercises [पृष्ठ ४५]
