c语音集训--郑伊杭--第二次作业

179 阅读2分钟

听课笔记

1c编程预备计算机知识

image.png

image.png

image.png

2基本输入与函数输出

image.png

  • 字符

    • 单个字符用单引号括起来:‘A’
    • 字符串用双引号括起来: “AB”

image.png

image.png

Ubuntu Pastebin 代码分享

乌本图·帕斯泰宾 (ubuntu.com)

image.png

名词翻译

中文英文中文英文
整数integer变量variable
字符character初始化initialize
浮点数float十进制decimalism
结构体structural body二进制binary system
枚举enumeration十六进制hexadecimal
联合unite打印printf

课后习题

3.10第四题

a.表示字符类型常量,“\”表示转义
b.是一个int型数据常量
c.表示双精度浮点类型常量
d.表示十六进制int类型常量
e。双精度浮点类型常量

第六题

常量类型转换说明
12int%d
0X3unsigned int%#x
'C'char%c
2.34E07double%e
'\040'char%e
7.0double%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
}

image.png

第二题

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

image.png

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;

}

image.png

第四题

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

image.png

第七题

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

image.png