69.3k views
2 votes
Which of these uses of type casting will NOT ensure that f is 1.5?

int a(1), b(2), c(2), d(2), e(2); double f; f = (a + b)*c / static_cast(d + e); // (ex1) f = static_cast(a + b)*c / (d + e); // (ex2) f = (a + b)*static_cast(c) / (d + e); // (ex3) f = static_cast((a + b)*(c) / (d + e)); // (ex4)

a. ex4
b. ex1
c.ex2
d. ex3

1 Answer

6 votes

Answer:

a. ex4

Step-by-step explanation:

The option a, which have thie function;

f = static_cast<double>((a+b)*(c)/(d+e)); gives a value of 1.

User Ruturaj
by
5.4k points