• 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; 
    }

  • 相关阅读:
    Windows逆向分析入门(六)——实战篇(用户信息)
    Windows逆向分析入门(五)——工具篇
    Windows逆向分析入门(四)——代码篇
    Windows逆向分析入门(三)——方法篇
    Windows逆向分析入门(二)——原理篇
    Windows逆向分析入门(一)——总篇
    WeTool的实现原理是什么呢?
    处理器如何实现原子操作
    如何保证对象在线程内唯一
    渣渣写算法之队列
  • 原文地址:https://www.cnblogs.com/liujiaxin2018/p/15068431.html
Copyright © 2020-2023  润新知