zoukankan      html  css  js  c++  java
  • c primer plus 3.11

    1、

    #include <stdio.h>
    #include <float.h>
    #include <limits.h>
    
    int main(void)
    {
    int big_int = 2147483647;
    
    float big_float = 3.4E38;
    
    float small_float = 10.0/3;
    
    printf("The big int data is %d
    ", big_int + 1);
    
    printf("The big float data is %f
    ", big_float * 10);
    
    printf("The big float data is %f
    ", small_float);
    
    printf("The MAX float data is %f
    ", FLT_MAX);
    
    printf("The max int data is %ld
    ", INT_MAX);
    
    return 0;    
    } 

    3.11-2

    #include <stdio.h>
    
    int main(void)
    {
        int ch;
        
        printf("please input an number for char type: ");
        scanf("%d", &ch);
        
        printf("%d is equivalent to %c.
    ", ch, ch);
        
        return 0;
    }

    3.11-3

    #include <stdio.h>
    
    int main(void)
    {
        char alarm = 'a';
        printf("%c", alarm);
        
        printf("xxxxxxx.
    ");
        printf(""yyyyyyyyy".
    ");
        
        return 0;
    }

    3.11-4

    #include <stdio.h>
    
    int main(void)
    {
        float test;
        
        printf("please input an float value: ");
        scanf("%f", &test);
        
        printf("fixed-point notation: %f.
    ", test);
        printf("exponential notation: %e.
    ", test);
        printf("p notation: %a.
    ", test);
        
        return 0; 
    }

    3.11-5

    #include <stdio.h>
    
    #define SEC_PER_YEAR 3.156e7
    
    int main(void)
    {
        float age, second;
        
        printf("please input your age: ");
        scanf("%f", &age);
        
        second = SEC_PER_YEAR * age;
        
        printf("your age is %.2f.
    ", age);
        printf("your age is equivalent to %e seconds.
    ", second);
        
        return 0;
    }

    3.11-6

    #include <stdio.h>
    
    #define GRM_PER_MOLE 3.0e-23
    #define GRM_PER_QUART 950
    
    int main(void)
    {
        float guart, gram, molecular;
        
        printf("please input the quarts: ");
        scanf("%f", &guart);
        
        gram = guart * GRM_PER_QUART;
        molecular = gram / GRM_PER_MOLE;
        
        printf("the number of water molecular: %e.
    ", molecular);
        
        return 0;
    }

    3.11-7

    #include <stdio.h>
    
    #define CENTIMETER_PER_INCH 2.54
    
    int main(void)
    {
        float height_inch, height_centimeter;
        
        printf("please input your height in inch: ");
        scanf("%f", &height_inch);
        
        height_centimeter = height_inch * CENTIMETER_PER_INCH;
        
        printf("your height in centimeter is: %.1f.
    ", height_centimeter);
        
        return 0;
    }

    3.11-8

    #include <stdio.h>
    
    int main(void)
    {
        float cups;
        
        printf("please input cups: ");
        scanf("%f", &cups);
        
        printf("pint: %.1f
    ", cups/2);
        printf("ounce: %.1f
    ", cups * 8);
        printf("big spoon: %.1f
    ", cups * 8 * 2);
        printf("tea spoon: %.1f
    ", cups * 8 * 2 * 3);
        
        return 0; 
    }

  • 相关阅读:
    Visual Studio 2005 Starter Kits
    怎样去做才是朋友?
    C#读写日志文本文件
    [文摘20080707]马云追加投资20亿 淘宝首定10年超沃尔玛目标
    [转]在WinForm应用程序中实现自动升级
    [转]官方Flash CS3简体中文帮助文档下载,AS3.0简体中文帮助文档下载
    [引]MySQL INNODB类型表的外键关联设置
    [转]winfrom让弹出的MessageBox在指定时间内自动销毁
    生活开心一笑 之 "我家半"与"QQ病毒"
    [English20080721]疯狂英语365句
  • 原文地址:https://www.cnblogs.com/liujiaxin2018/p/15068431.html
Copyright © 2011-2022 走看看