There are lots of ways. Probably the simplest is to tell the compiler to
cast
Fahrenheit to int e.g.
printf("Fahrenheit = %d\n", (int)Fahrenheit);
The
(int)
is known as a
cast and tells the compiler to convert the given type to the requested types. Alternatively you could assign the float value to an int e.g.
int Fahrenheit_int = Farenheit;
printf("Farenheit = %d\n", Fahrenheit_int);
Be aware that the conversion from floating point to int
truncates the value so that (int)32.2 = 32, and (int)32.99 = 32. You might want to think about how you could get the int value of the value to be the closes int rather than the int closest to zero.
There are other possibilities too, you could look into the
round()
function in the C library, but that might cause linking issues, since it may be part of the math library.