Exercise 1-15 Rewrite the temperature conversion program in section 1.2 and use the function to achieve temperature conversion calculations.
The code is as follows:
#include <stdio.h>//contains information about the standard library. floatFahrtocelsius (floatFahr);floatCelsiustofahr (floatCelsius);intMain ()//defines a function named Main, which does not accept parameter values. {printf ("1 degrees Fahrenheit is equal to%.1f degrees Celsius .", Fahrtocelsius (1)); printf ("\ n"); printf ("1 degrees Celsius, etc Yu Hua%.1f degrees", Celsiustofahr (1)); GetChar (); //prevent the console from flashing through, you need to accept any characters after you close the console. return 0;//returns a shape to the execution environment, and 0 represents a successful execution. }floatFahrtocelsius (floatFahr) { return(5.0/9.0) * (Fahr-32.0);}floatCelsiustofahr (floatCelsius) { return(9.0/5.0) * Celsius +32.0;}
Personal Understanding:
Used to learn how to declare and implement functions, and invoke them.
C Programming language Exercises 1-15