Title: Input Fahrenheit temperature F, output corresponding to C, 3 decimal places reserved.
Tip: C=5 (f-32)/9
(1) Declaring floating-point type variable f,c, respectively, representing the input Fahrenheit temperature and the output Celsius temperature
double F; // double C; // Celsius temperature of the output
(2) input Fahrenheit temperature F:
scanf ("%lf", &f);
(3) Assign the variable C according to the conversion formula of c=5 (F-32)/9:
C= (double) (5* (f-a)/9);
(4) Output Celsius temperature c:
printf ("%.3lf", c);
Full code:
//P16 Exercise 1-2 temperature#include <cstdio>DoubleF//temperature of the input FahrenheitDoubleC//Celsius temperature of the outputintMain () {scanf ("%LF",&G); C=(Double)(5* (f +)/9);//c=5 (f-32)/9printf ("%.3LF", c); return 0; }
Introduction to the C + + algorithm race Classic Page16 exercise 1-2 temperature