हिंदी

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;

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

उत्तर

  1. b++ (Postfix): Uses the current value of b (6) in the expression, then increments b to 7.
  2. d-- (Postfix): Uses the current value of d (12) in the expression, then decrements d to 11.
  3. ++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
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 1: Revision of Class 9 Syllabus - Exercises [पृष्ठ ४५]

APPEARS IN

रुपा पंडित Computer Applications [English] Class 10 ICSE
अध्याय 1 Revision of Class 9 Syllabus
Exercises | Q 3. (i) | पृष्ठ ४५
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×