Computer Science, asked by GLiQueofficial, 7 days ago

What is the type and value of the following expression? (Notice the integer division) -4 + 1/2 + 2*-3 + 5.0

Answers

Answered by queenpayal1276
14

Explanation:

-4 + 1/2 + 2*-3 + 5.0

A.

int -5

B.

double -4.5

C.

None of the above

D.

double -5.0

Answered by Qwparis
0

The correct answer is -5.0.

Given: The expression = -4 + 1/2 + 2*-3 + 5.0.

To Find: The type and value of the expression.

Solution:

-4 + 1/2 + 2*-3 + 5.0

Applying BODMAS rule. Firstly divide the numbers.

After dividing 1 and 2, 0.5 will come but as 1 and 2 both are integers the output should also be integer. So it will take 0 as output.

= -4 + 0 + 2*-3 + 5.0

= -4 -6 + 5.0

= -10 + 0.5

As 0.5 is float so the 10.0 will be subtracted from 5.0 and the output will be in float.

= -5.0

Hence, the answer is -0.5.

#SPJ3

Similar questions