foreword: At present in the study K&r's book "C Programming Linguistics", because has not contacted the C language for several years, therefore this re-study, absorbed the online predecessor's experience: develops the good writing code style and through the blog study summarizes and ponders. today read the book on the Fahrenheit temperature and Celsius temperature conversion table procedures for floating-point and integer data have a preliminary understanding. In practice exercise 1-3, the answer code was first knocked over the vc++6.0, even so, still found some of the problems are as follows:1. The format control string is used to specify the output format. The format control string can consist of both a format string and a non-formatted string. The format string is a string beginning with%, followed by a variety of format characters in%, to indicate the type, form, length, scale, etc. of the output data;2.printf format output function in the "number again forgot to knock;3. There is a sentence to forget the semicolon. The code is as follows:
#include <stdio.h>
/* Print Fahrenheit-Celsius when Fahrenheit temperature equals 0,20,...,300d temperature conversion table; This time using the floating-point version of the data */
void Main ()
{
float Fahr,celsius;
int lower,upper,step;
lower=0; /* Lower limit of temperature table*/
upper=300; /* Upper Limit */
step=20; /*step Size */
printf ("Fahr celsius\n");
Fahr=lower;
while (Fahr<=upper)
{
celsius= (5.0/9.0) * (fahr-32.0);
printf ("%3.0f%6.1f\n", Fahr,celsius);
Fahr=fahr+step;
}
GetChar ();
}
C Programming Language Learning < a >