Computer Science, asked by chandankumarsahu, 1 year ago

evaluate the following c++ expressions where a,b,c are integers and d,f are floating point numbers . The values are : a=3,b=5,and d=1.5. (A) c=a+++b*++d (B) f=b*b++-++a

Answers

Answered by devkalwani
45
Value of a = 3, b = 5, d = 1.5

(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

(B) 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
Answered by ananya31838
5

Answer:

Value of a = 3, b = 5, d = 1.5

(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

(B) 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

Explanation:

Similar questions