码迷,mamicode.com
首页 > 其他好文 > 详细

<C Primer Plus>8 The if statement

时间:2017-04-02 21:19:22      阅读:181      评论:0      收藏:0      [点我收藏+]

标签:blog   res   primer   include   number   turn   express   class   data   

 1 #include <stdio.h>
 2 #include <math.h>
 3 int main(void){
 4     const int FREESEING = 0;
 5     float temperature;
 6     int cold_days = 0;
 7     int all_days = 0;
 8 
 9     printf("Please input the temperature:\n");
10     printf("q is quit.\n");
11     while (1 == scanf("%f", &temperature)){
12         all_days++;
13         if (temperature < FREESEING){
14             cold_days++;
15         }
16     }
17     if (all_days != 0){
18         printf("The number of all_days = :%d ", all_days);
19         printf("The cold day = %d \n", cold_days);
20         printf("the cold day %.2f%% of all day.\n", 100.0*(float)cold_days / all_days);
21     }
22     else{
23         printf("input no data.\n");
24     }
25 
26     return 0;
27 }

if (expression)

  statement

<C Primer Plus>8 The if statement

标签:blog   res   primer   include   number   turn   express   class   data   

原文地址:http://www.cnblogs.com/michael2016/p/6659727.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!