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
Related Questions
If a = 5, b = 9, calculate the value of a in the following expression:
a += a++ - ++b + aWhat will be the output of the following if x = 5 initially?
(a) 5* ++x;
(b) 5* x++;
Evaluate the following expressions if the values of the variables are a = 2, b = 3, and c = 9.
(a) a - (b++) * (--c);
(b) a * (++b) % c;
What will be the output of the variable 'a'?
int a=0,b=10,c=40; a = --b + c++ + b; System.out.println(" a = " + a);