Solution for Exercise 10-10
ex1010
#include <stdio.h>
float convert(float f);
int main()
{
float temp_f;
printf("Temperature in Fahrenheit: ");
scanf("%f",&temp_f);
printf("%.1fF is %.1fC\n",temp_f,convert(temp_f));
return(0);
}
float convert(float f)
{
float t;
t = (f - 32) / 1.8;
return(t);
}
Notes
* The "other change" mentioned in the book is the removal of the temp_c variable, which is no longer needed. It had to be removed at Line 7 (not declared) and from Lines 11 and 12 in the original code.
* The compiler may warn you when unused variables exists in your code.
Copyright © 1997-2025 by QPBC.
All rights reserved
