Advertisements
Advertisements
प्रश्न
Evaluate the following expression where prefix and postfix increment and decrement operator is used.
int b = 6, d = 12,c = 0;
c = b++ + d-- + ++ b;
System.out.println ("B=" + b+" D=" + d+" C=" +c);
मूल्यांकन
Advertisements
उत्तर
b++(Postfix): Uses the current value of b (6) in the expression, then increments b to 7.d--(Postfix): Uses the current value of d (12) in the expression, then decrements d to 11.++b(Prefix): Increments b first (from 7 to 8), then uses this new value (8) in the expression.
- C = 6 + 12 + 8 = 26
- B = 8
- D = 11
shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
