I'm writing a program for a class I'm in and need some help with a program for converting Fahrenheit to Celsius in C. My code looks like this
#include <stdio.h>
int main (void)
{
int fahrenheit;
double celsius;
printf("Enter the temperature in degrees fahrenheit:\n\n\n\n");
scanf("%d", &fahrenheit);
celsius = (5/9) * (fahrenheit-32);
printf ("The converted temperature is %lf\n", celsius);
return 0;
}
Every time I execute it it the result is 0.000000. I know I'm missing something but can't figure out what.
write
5/9.0
instead of 5/9 -- this forces double division