English

If a = 12, give the value of the following expression: (a++) + (--а)

Advertisements

Question

If a = 12, give the value of the following expression:

(a++) + (--а)

Numerical
Advertisements

Solution

Given: a = 12

Expression: (a++) + (--a)

The post-increment operator (a++) first uses the current value of a and then increases it by 1. The pre-decrement operator (--a) first decreases the value of a by 1.

a++ = 12 (then a = 13)

--a = 13 − 1 = 12

Therefore,

= 12 + 12

= 24

  • Value of expression ((a++) + (--a)) = 24
  • New value of a = 12
shaalaa.com
  Is there an error in this question or solution?
Chapter 6: Variables and Expressions - EXERCISE [Page 135]

APPEARS IN

Dheeraj Mehrotra Computer Science [English] Class 12
Chapter 6 Variables and Expressions
EXERCISE | Q 59. (g) | Page 135
Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×