0

When I am doing:

(a)

int fah1 = 0:

float fah_to_cel1 = (fah1 - 32) / 9 * 5;

The value of fah1 still remains -15 which is similar when I declare fah_to_cel1 as int.

But when I do:

(b)

int fah1 = 0;

float fah_to_cel1 = ((float)fah1 - 32) / 9 * 5;

Then I get fah_to_cel1 as -17.777777778 which is right.

Why there is a need to explicitly convert the fah_to_cel1 to float to get the right answer?

Rohan
  • 55
  • 6

0 Answers0