Beginner problem with floats
Hi everyone,
I'm working through the Kochan book "Programming in C". I was doing fine following along until chapter 4, exercise 4. I'm trying to write a conversion program using C = ( F - 32 ) / 1.8 . Here's what I came up with:
Code:
#include <stdio.h>
int main (void)
{
//declare variables
float f1;
float c1 = ( f1 - 32 ) / 1.8;
//print result
f1 = 27;
printf ("27 degrees Farenheit = %f degrees Celsius\n", c1);
return 0;
}
My program returns −17.77, so I'm thinking maybe I declared the float variables wrong and it only reads -32/1.8 ? Any help would be appreciated, thanks.