C Programming Language Learning < a >

Source: Internet
Author: User

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 >

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.