Computer Science, asked by ApratimDutta, 4 months ago

Q
if
a =5
b = 9
then calculate
a+ = a++ - ++b + a​

Answers

Answered by allysia
1

Answer:

6

Explanation:

  • initial values:

a = 5

b= 9

  • a++ holds the value of 5( and the next time you use a in this program it will have it's value increased by 1).
  • ++b holds the increased value of b by 1 which is 10.
  • a now has increased value of 6.

The expression therefore becomes,

a = a + (a++) -(++b) + a

= 5 + 5 - 10 + 6

= 6.

In order to understand this better consider the following example.

a = 0 #printing a returns 0

a++ #printing a returns 0

a #printing a returns 1

b = 0 #printing a returns 0

++b #printing a returns 1

b #printing a returns 1

Similar questions