资源描述:
《零基础学习c语言习题答案》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、第一篇C语言基础第1章1.voidmain(void){printf(“HelloWorld!”);}第2章1.voidmain(void){printf("你好,C语言!");}2.voidmain(void){printf("");printf("");printf("");printf("");printf("");}3.voidmain(void){printf("1");printf("2");printf("3");printf("4");printf("5"
2、);}第3章1.#includeintsum1(inta,intb);voidmain(void){inta=10,b=20;inty=sum1(a,b);printf("theaverageis%d",y);}intsum1(inta,intb)第一篇C语言基础{returna+b;}2.错误是代码声明的语句intadd(inta,intb)后面没带分号。3.#include#include"sum1.txt"voidmain(void){inta=10,b=20;inty=s
3、um1(a,b);printf("theaverageis%d",y);}其中sum1.txt的内容如下intsum1(inta,intb){returna+b;}第4章1.#includevoidmain(void){intx;x=100;x=x+102;x=x+104;x=x+106;x=x+108;x=x+110;printf("100+102+104+106+108+110=%d",x);}2.#includevoidmain(void){floatf_radius=
4、3.0;/*半径*/floatf_area=3.1415926*f_radius*f_radius;/*计算圆面积*/printf("圆面积=%f",f_area);}第5章第一篇C语言基础1.#includevoidmain(void){printf("+%20s+%5s+","--------------------","------------");printf("
5、%20s
6、%5s
7、","姓名","年龄");printf("+%20s+%5s+","--------------
8、------","------------");printf("
9、%20s
10、%5d
11、","朱莉",22);printf("
12、%20s
13、%5d
14、","李思思",28);printf("
15、%20s
16、%5d
17、","王小明",23);printf("
18、%20s
19、%5d
20、","凡尘",24);printf("+%20s+%5d+","--------------------","------------");}2.#includevoidmain(void){intnum=0;printf(
21、"输入身份证号:");scanf("%*14d%4d",&num);printf("后4位是:%4d",num);}第6章1.mx=0m22、
23、y-1>x=1!(y-1>x)=12.最后的输出结果是4,但a的值是0a的值是16a与b比较的结果=0第7章#include#includevoidmain(void){inttotal=0;printf("请输入一个分数:");scanf("%d",&total);if(total<60){printf("不及格!"
24、);第一篇C语言基础}else{printf("及格!");}getch();}第8章1.100,100,1002.10第9章1.**2.a=0,b=4第10章1.少了#include语句2.#includedoublemoney(intx);voidmain(){intmymoney;printf("inputamoney:");scanf("%d",&mymoney);printf("thelastmoneyis%.2f",money(mymoney));}doublemoney
25、(intx){doublelastmoney=x+x*3.10/100/12*3;/*3.10ÊÇ3¸öÔ´æ¿îµÄÀûÏ¢*/returnlastmoney;}第11章1.#includevoidmain(){第一篇C语言基础chars[]="abcdefgh";inti;for(i=0;i<8;i++)p