What is the type and value of the following expression? (Notice the integer division) -4 + 1/2 + 2*-3 + 5.0
1) int -5
2) double -4.5
3) int -4
4) double -5.0
Answers
Answered by
4
Answer:
-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
0
Answer:
The correct answer is option (4) i.e. double -5.0
Explanation:
-4 + 1/2 + 2*-3 + 5.0
In this expression, even you apply integer division, answer still will be a decimal number.
The reason behind this is adding +5.0 to the expression. Whenever, we add a decimal number to integer number or expression, answer will always be decimal number. So double -5.0 is correct.
#SPJ3
Similar questions