Computer Applications
What will be the output of the following if x = 5 initially?
(a) 5* ++x;
(b) 5* x++;
Java
Java Operators
161 Likes
Answer
(a) 5* ++x;
30
Working
5* ++x
⇒ 5* 6 [∵ ++x will first increment x to 6 and then use it in the expression]
⇒ 30
(b) 5* x++;
25
Working
5* x++
⇒ 5* 5 [∵ x++ will first use the current value of x in the expression which is 5. After that x is incremented to 6]
⇒ 25
Answered By
70 Likes
Related Questions
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;
If m = 5 and n = 2, predict the output values of m and n:
(a) m -= n;
(b) n = m + m/n;
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);
If a = 5, b = 9, calculate the value of a in the following expression:
a += a++ - ++b + a