C语言集训-赵鸿志-第二次作业

233 阅读2分钟

一、课堂笔记

1.基本类型数据

QQ图片20211121131146.png

2.常量在C语言中是如何表示的

QQ图片20211121131303.png QQ图片20211121131347.png

3.printf的使用

QQ图片20211121131537.png

4.scanf的使用

QQ图片20211121123941.png

二、翻译

中文英文中文英文
整数integer变量variable
字符character初始化initialization
浮点数Floating point number十进制decimal system
结构体structural morphology二进制Binary
枚举enumeration十六进制hexadecimal
联合union打印Print

三、课后作业

1、3-10第四题

a. '\b',单引号表示字符类型常量,''表示转义,'\b'表示退格;

b. 1066是一个整数型常量;

c. 99.44表示双精度浮点型数据常量;

d. 0xAA表示十六进制无符号整数类型数据常量;

e. 2.0e30表示双精度浮点型数据常量。

2、3-10第六题

常量类型转换说明符
12int%d
0X3Unsigned int%#X
‘C’char%c
2.34E07double%e
‘\040’Char%c
7.0Double%f

3、3-10第八题

printf("The odds against the %d were %ld to 1.\n",imate,shot);
printf("A score of %f is not an %c grade.\n",log,grade).

4、3-11第一题

1.整数上溢

QQ图片20211121153430.png

2.浮点数上溢

QQ图片20211121153843.png

3.浮点数下溢

QQ图片20211121154244.png

5、3-11第二题

#include <stdio.h>

int main(void)
{
    int i = 66;
    
    printf("%c\n", i);

    return 0;
}

QQ图片20211121151521.png

6、4-8第一题

#include <stdio.h>
int main(void)
{
    char name[40];
    char surname[40];
    printf("Please input your first name:");
    scanf("%s",name);
    printf("Please input your last name:");
    scanf("%s",surname);
    printf("%s,%s.",name,surname);
    return 0;
}

7、4-8第四题

#include <stdio.h>
int main()
{
    float heigh;
    char name[40];
    printf("Enter your name :");
    scanf("%s",name);
    printf("%s, how tall you are(inch) :",name);
    scanf("%f",&heigh);
    printf("%s,you are %.3f feet tall \n",name,heigh/12.0);
    
    return 0;
}

QQ图片20211121161851.png

8、4-8第七题

#include <stdio.h>
#include <float.h>
int main(void)
{
    double d_third = 1.0 / 3.0;
    float f_third = 1.0 / 3.0;
    printf("float of one third(6) = %.6f\n",f_third);
    printf("float of one third(12) = %.12f\n",f_third);
    printf("float of one third(16) = %.16f\n",f_third);
    printf("double of one third(6) = %.61f\n",d_third);
    printf("double of one third(12) = %.121f\n",d_third);
    printf("double of one third(16) = %.161f\n",d_third);
    printf("FLT_DIG in float.h is %d\n",FLT_DIG);
    printf("DBL_DIG in float.h is %d\n",DBL_DIG);
    return 0;
}

QQ图片20211121162919.png