zoukankan      html  css  js  c++  java
  • <C Primer Pus>6 Using Relational Operators and Exprssions

     1 while(number < 6){
     2     printf("Your number is too small.
    ");
     3     scanf("%d", &number);                
     4 }
     5 
     6 
     7 while(ch != '$'){
     8     count++;
     9     scanf("%c", &ch);
    10 }    
    11 
    12 
    13 while(scanf("%f", &num) == 1){
    14     sum = sum +num;
    15 }
     1 #include <stdio.h>
     2 #include <math.h>
     3 int main(void){
     4     const double ANSWER = 3.14159;
     5     double respone;
     6 
     7     scanf("%lf", &respone);
     8     while (fabs(respone - ANSWER) > 0.0001){
     9         printf("Try again.
    ");
    10         scanf("%lf", &respone);
    11     }
    12 
    13     printf("Close enough.
    ");
    14 
    15     return 0;
    16 }

    REMEBER :

    You should limit yourself to using only < and > in floating-point comparisons.

    while(status == 1)  is ture.  and  while(status = 1) is ture ....so advice to write like that  while(1 == status).

  • 相关阅读:
    pinyin4j使用示例
    迭代器模式
    适配器模式
    策略模式
    装饰模式
    责任链模式
    命令模式
    中介者模式
    原型模式
    代理模式
  • 原文地址:https://www.cnblogs.com/michael2016/p/6658693.html
Copyright © 2011-2022 走看看