KnowledgeBoat Logo

Output Questions for Class 10 ICSE Computer Applications

If m = 5 and n = 2, predict the output values of m and n:

(a) m -= n;

(b) n = m + m/n;

Java

Java Operators

199 Likes

Answer

(a) m -= n;

m = 3
n = 2

Working

    m -= n
⇒ m = m - n
⇒ m = 5 - 2
⇒ m = 3
Value of n is unchanged so it is 2.

(b) n = m + m/n;

m = 5
n = 7

Working

    n = m + m/n;
⇒ n = 5 + 5/2;
⇒ n = 5 + 2;     [∵ 5/2 is integer division so result is 2]
⇒ n = 7
Value of m is unchanged so it is 5.

Answered By

105 Likes