听课笔记
1c编程预备计算机知识
2基本输入与函数输出
-
字符
- 单个字符用单引号括起来:‘A’
- 字符串用双引号括起来: “AB”
Ubuntu Pastebin 代码分享
名词翻译
| 中文 | 英文 | 中文 | 英文 |
|---|---|---|---|
| 整数 | integer | 变量 | variable |
| 字符 | character | 初始化 | initialize |
| 浮点数 | float | 十进制 | decimalism |
| 结构体 | structural body | 二进制 | binary system |
| 枚举 | enumeration | 十六进制 | hexadecimal |
| 联合 | unite | 打印 | printf |
课后习题
3.10第四题
a.表示字符类型常量,“\”表示转义
b.是一个int型数据常量
c.表示双精度浮点类型常量
d.表示十六进制int类型常量
e。双精度浮点类型常量
第六题
| 常量 | 类型 | 转换说明 |
|---|---|---|
| 12 | int | %d |
| 0X3 | unsigned int | %#x |
| 'C' | char | %c |
| 2.34E07 | double | %e |
| '\040' | char | %e |
| 7.0 | double | %f |
第八题
分别填入d ld f c
3.11第一题
#include<stdio.h>
#include<float.h>
#include
int main(void) {
int big_int = 2147483647;
float big_float = 3.4e38;
float small_float = 10.0/3;
printf("The big int date is %d\n",big_int+1);
printf("The big float date is %f\n",big_float*10);
printf("The big float date is %f\n",small_float);
printf("The MAX float date is %f\n",FEL_MAX);
printf("The MAX int date is ld\n",INT_MAX);
return 0
}
第二题
#include<stdio.h>
int main (void){
int input;
printf("Enter a value of char int ASCII:");
scanf("%d",&input);
printf("You input value is %d, and char is %c\n",input,input);
return 0;
}
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 ("hello, %s ,%s.",name ,surname);
return 0;
}
第四题
#include<stdio.h>
int main() {
float heigh;
char name[40];
printf("Enter your name :");
scanf("%s",name);
printf("hi %s,how tall you are (inch):",name);
scanf("%f",&heigh);
printf("%s, you are %.3f feet tall \n",name,heigh/12.0);
return 0;
}
第七题
#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) = %.6lf\n",d_third);
printf("double of one third(12) = %.12lf\n",d_third);
printf("double of one third(16) = %.16lf\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;
}