Predict the output:

```c
#include

int main() {
float c = 5.0;
printf("Temperature in Fahrenheit is %.2f", (9/5) * c + 32);
return 0;
}
```

A. Temperature in Fahrenheit is 41.00
B. Temperature in Fahrenheit is 37.00
C. Temperature in Fahrenheit is 0.00
D. Compiler Error

Answer :

Option B.The program incorrectly calculates Fahrenheit because (9/5) evaluates to 1 using integer division. Therefore, the output is Temperature in Fahrenheit is 37.00.

This question pertains to temperature conversion in a C programming context, where the program outputs the temperature in Fahrenheit.

The computed output is derived from the formula for converting Celsius to Fahrenheit,
(9/5)*c + 32.
In the provided code, the expression (9/5) evaluates to an integer division and results in 1 instead of 1.8.
Therefore, the actual calculation becomes:

(1) * 5.0 + 32 = 5.0 + 32 = 37.00

Thus, the correct answer is option B: Temperature in Fahrenheit is 37.00

Other Questions