Computer Science, asked by pr257997, 8 months ago

Q. Evaluate the following C++ expression where a, b, c are
integers and d, fare floating point numbers. The values are a = 5, b=3
and d= 1.5.
(a) c = (a++) * d + a
(b) f = a++ * b++
(c) f= (++b) * b-a
(d) c = a - (b ++) * ( --d)
(e)" f= a + b / a
(f) c = d * a + b​

Answers

Answered by rajdas23218
0

Explanation:

(A) c=a++ + b * ++d

Here, c is a integer. So, all the no. will be treated as integers.

Now,

c = a++ + b * ++d

Here, a is post incrementated. So, it'll follow the USE THEN CHANGE method.

And d is pre incrementated. So, it'll follow the CHANGE THEN USE method.

c = 3 + 5 * 2 [value of a changes to 4 after use]

Value of d will be 2.5 but since c, the answer, is integer, we'll only take the value of d as 2.

c = 3 + 10

c = 13

(c) f = b* b++ - ++a

f is a floating point therefore the answer will also be a floating point number and all numbers will be treated as floats.

f = 5 * 5 - 5

value of was 4. It has pre increment operator which implies CHANGE THEN USE rule. So, the value, here, becomes 5.

Now,

f = 25 - 5

f = 20

Similar questions