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).

  • 相关阅读:
    24/3=8 睡觉8工作8 8????
    linux上使用redis--宝塔面板
    Ruby--strftime
    JS-页面操作
    JS-确认框
    Rails--bundle exec rake db:migrate
    Jquery--array
    Ruby--hash
    Jquery--string
    Jquery--ajax
  • 原文地址:https://www.cnblogs.com/michael2016/p/6658693.html
Copyright © 2011-2022 走看看