版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、program. )program. )program. )total is:第一章 C 语言初步一、 选择题l. C 2.D 3.D 4.A 5.D7.B 8.B 9.C 10.A二、 思考与应用题1. A. 字符串常量B. 字符串常量C. 整型常量D. 浮点型常量 (double)2. A. long doubleB. long intC. floatD. 字符型常量3. A. 整型常量B. 字符型常量C. 字符串常量D. 字符串常量4.FirstExample : 10,w is Y z is 5. 124. int main(void) return 0;5. #include int
2、 main(void) printf(Hello World); return 0;)6. #include int main(void) (printf( Z/We are to learn correct); printf(C language here);return 0;/*main*/7. #include int main(void)(/*Local Definition*/ int a; float b; char c;nstateme nts*/6.Bprintf (The end of thereturn 0; Amain*/9. #include int main(void
3、) /*Local Definition*/ int a;float b; char c, d;FStatemen ts*/printf (The end of thereturn 0; Amain*/10. #include int main(void) /*Local Definition*/ int a; char b, c, d; float e, f;/*Statements*/printf(The end of thereturn 0;/*main*/11. A. char option;B. int sum=0;C. float produce=l;12. A. short co
4、de;B. float salesTax=. 0825;C. double sum=0;13. #include int main(void) float cost=172.53; printf(Thesalesn”, cost);printf(a “、);return 0;14. #include int main(void)printf (*n);int xl;prin tf(*n);int x2;prin tf(*n); prin tf(*n);return 0;int x3;prin tf(Please numbers: );scanf(en ter three/% d%d%” , &
5、xl, &x2, &x3);15. #in cludevstdio. hprintf(/nYourint mai n(void)forword:n );n umber(prin tf(* n);printf(/,xl, x2, x3pri ntf(*n); printf (*nprintf(reversed:n ,z);/Yourn umberpri ntf(*nprintf(/,x3, x2, xlreturn 0;16. #i ncludereturn 0;int mai n(void)#in cludevstdio. hint xl=l;int mai n(void)int x2=10;
6、int xl;int x3=100;int x2;3, x4, x5);3, x4, x5);int x4=1000; int x5=10000;zpri ntf (n”,xl, x2, xpri ntf C%fn”,xl, x2, xreturn 0;17. #in cludevstdio. h int main( void) int x;prin tf(Pleaseinteger: n,z);enterint x3;int x4;int x5;int x6;int x7;int x8;int x9;int xlO; prin tf(Pleaseenter10numbers:n );sca
7、nf(%d%d%d%d%d%d%d%d%d%d,&x2, &x3, &x4, &x5, &x6, &x7, &x8, &x9, an &xl0);printf (,znYour numbers are: nzJscanf ( %d , &x);prin tf(The character: %cn ,z, x);prin tf(The刀n , x);n umbern umberasas,xl, xlO);,x2, x9);prin tf(%8d%8dnprin tf(Thefloat :%fn,z, x);nu mberasreturn 0;return 0;)#in cludevstdio.
8、hint main( void)二、编程题1. #in cludevstdio. hint xl;int x2;int mai n(void)int x3;int x4;,x3, x8);,x4, x7);,x5, x6);int x5;int x6;int x7;int x8;int x9;printf (Input:n);prin tf();sea nf(%d%d%d%d%d%d%d%d%dl,&x2, &x3, &x4, &x5, &x6, &x7, &x8, &x9);printf( nOutputn );n” , xl, x2, x3);n” , x4, x5, x6); n” ,
9、x7, x8, x9);return 0;第二章表达式与简单程序设计一、选择题int x, y,乙LA 2.D3.C4.B5.B6.D7.Bprintf(Please enter two integers:n);二、思考与应用题scanf(%d%d” , &x, &y);1.A.2B.8C.8D.OE. 11z=x*y;2. A. 4, 4 B. 4, 4 C. 4, 4 D.2, 3 E. 4,printf (%d*%d=%d ” , x, y, z);5return 0;3. A. 12B.-27C. 14D. 2E. 4)4. A. 22.52 B. 4.5C. 13.333333 D.
10、 0.88235312. #includeE. 0.07int main(void)5. ABCEF(6. A. 5B. 2C. 4D. 1E.float x;7. A. 5B. 2C. 4D. -3E. 6int y;8. A.5B.294C.4D. 29E. 9printf(Please enter a floating point9.50 50 100 25number:n);10. #includescanf(%f ” , &x);int main(void)(float x;y=(int)x%10;float y;printf(%d ” , y);float p;return 0;f
11、loat s;)float total;13. #includeprintf(Please enter x and y:n);int main(void)scanf(%f%f ”,&x, &y);(P 二 x*y;float x;s=x+y;int y;total=s*s+p*(s-x)*(p+y);printf(Please enter a floating pointprintf(total=%f ,total);number: n);return 0;scanf(%f ” , &x);y=(int)x/10%10;11. #includeprintfy);int main(void)re
12、turn 0;14. #include int main(void)float x;float y;float c;float s; printf(Please enter length and width:n); scanf (%f%f, &x, &y);c=2*(x+y);s=x*y;printf(The circumference is %fn , c); printf(The measure of area is %f”, s);return 0;15. #includeint main(void)(int a;float r;printf(Please enter an angle(
13、integer):n); scanf&a);r=a/57. 295779;printf(%d is %. 5f radians”, a, r);return 0;)16. #includeint main(void)float c;float F;printf(Please enter centigrade:n); scanf(%f ”, &c);F 二 32+(c*180. 0/100. 0);printfFahrenheit is %f” , F);return 0;17. (1) double m, v, KinEn;KinEn=m*v*v/2;(2) double b,c,res;re
14、s=(b+c)/ (2*b*c);18. (1) #includeint main(void)int x=25;x=x+5;x=x+5;printf( %dn, x);return 0;)(2) #include int main(void)int x=10;x=x+2;n” , x);x=x+2;printf( %dn, x);return 0;)(3) main(vo int id)#includeint x=32;x=x*2;printf( %dn, x);x 二 x*2;printf( %dn, x); return 0;)三、编程题1. A. #include int main(vo
15、id)float y;printf(Pleaseentnumber(inch):n);scanf(%f ” , &x);y=x/12;i %f feetprintf(%fx, y);inches return 0;B. #includeint main(void)float x;float x;float y;ent aprintf(Pleasenumber(inch):n);scanf(%f ” , &x);y=x/36;iprintf(%f inches return 0;%f yards x, y);printf(%dn, x);C. #include第三章分支程序设计l.、选择题C 2
16、.D3.A4.B5.B6.A7.C8.C9.A-二*、思考与应用题1.A.OB. 1C. 1D.OE.2.A. x=yBxy3.A.OB. 1C.1D. 1E.4.x 二 4, y=3, z=205.x 二 4, y=l, z=26.x 二 4, y=2, z二 27.x 二 4, y= 1, z二 28.x=0, y=0, z二 19.x 二 2, y 二 0,z 二 210x=0, y=0,z=l11x 二 0, y 二 0, z 二 112x=-l, y=0,z=013x 二 0, y= 1,z 二 014x=l, y=3,z=l15x=l, y=3, z二 116x=4, y=3,z=
17、017if (aChar二二 E)int main(void)(float x;float y;printf(Pleaseenterannumber(inch):n);scanf(%f ” , &x);y=x*2. 54;printf( f inches is %f centimeters ,x, y); return 0;D. #includeint main(void)float x;float y;printf(Pleaseenterannumber(inch):n);scanf(%f ” , &x);y=x/39. 37;printf( %f inches is %f meters ”
18、 , x, y); return 0;2. #includeint main(void)(int fibl;int fib2;int fib3;fibl二13+21;fib2二21+fibl;fib3二fibl+fib2;printf(z,%d, %d, %d” , fibl, fib2, fib3);return 0;3. #includeint main(void)(int x;int bl:int b2;int b3;int b4;int b5;printf(Pleaseenteraninteger(0-32767):n);scanf(%d ” , &x);bl=x%10;b2 二 x/
19、10%10;b3=x/100%10;b4=x/1000%10; b5=x/10000%10;n” , b5, b4, b3, b2, bl); printf ( z,%4d%4d%4d%4d%rb4, b3, b2, bl);n” , b3, b2,bl);n” , b2,bl);printf(%4d ” , bl);return 0;(c+;printf(Value is En);18. switch(ch)case E:case e :countE+;break;case W :countA+;break;case T:case i :countl+;break; default:prin
20、tf(AError-Not A, E, or lan);三、编程题1. #includemain()(int x, xl, x2, x3;char grade;printf(please enter three text scores(0-100):n);scanf(%d%d%d , &xl, &x2, &x3); x=(xl+x2+x3)/3;if(x=90) grade=A;else if(x=70& x90) grade=A ,;elsegrade=B;else if(x=50& x70)grade=C;elsegrade=D;else if(x50)grade=F;printf(n”,
21、grade);)2. #includemain()(int year;printf(please enter a year:n); scanf(%d ” , feyear);if (year%4=0&year%100!=0| | year%400=0)printf(%d is a leapn” , year);elseprintf(%d is a non-leapn”year);)3. #includemain()intyearNow, monthNow, dayNow, year, month, day, x;printf(Please enter the date today(month
22、day year):n );scanf (%d%d%c” , &monthNow, &dayNow, &yearNow);printf(Please enter your birthday(month day year):n );scanf( d%d%cl, &month, &day, &year);if(monthNowmonth)x=yearNow-year-1;else if(monthNow=month)if(dayNowday)x=yearNow-year-1;elsex=yearNow-year;elsex 二 yearNow-year;printf(You are %d year
23、s old!n, x);4. #include#include#includemain()(int number, Ynumber;srand(time(NULL);number=rand()%20+l;printf ( I am thinking of a number between 1 and20. n);printf(Can you guess what it is? ” ); scanf(%d ” , &Ynumber);if(Ynumber=numb er) printf(ACongratulations!You did it.” );else(if(Ynumbernumber)p
24、rintf(Your guess is high. Try again:); elseprintf(Your guess is low. Try again:); scanf(%d ” , &Ynumber);if(Ynumb er=number) printf(ACongratulations!You didit. ”);else(if(Ynumbernumber)printf(Your guess is high. Try again:); elseprintf(Your guess is low. Try again:); scanf(%d ” , feYnumber);if(Ynumb
25、er=number) printf(ACongratulations!You did it.” );else(if(Ynumbernumber)printf(Your guess is high. Try again:); elseprintf(Your guess is low. Try again:); scanf(%d ” , &Ynumber); if(Ynumber=number) printf(ACongratulations!You did it.” );if(Ynumbernumber)printf(Your guess is high. Try again:);elseels
26、scanf( %d , &Ynumber);if(Ynumber=number) printf(Congratulations!You did it.” );else(printf(sorry. Thenumbe rwas %d. n, number);printf(You should have gotten it by now.n );printf(ABetter luck next time. );)5. #includemain()(int year, month, day, x=0, y, z;printf(Please enter your birthday:(year month day)n );scanf(%d%d%d , feyear, &month, &day);y=(year-1)*365+(year-1)/4)-(year-1)/100)+(yearl)/400)%7;switch(month)(case 12:x=x+30;case 11:x=x+31;case 10:x=x+30;case 9:x=x+31;case 8:x
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 工贸企业安全标准化自评报告
- 油气井增产材料研发-洞察分析
- 眼科临床研究与眼部疼痛-洞察分析
- 业务对象模型标准化-洞察分析
- 文化产业价值评估体系-洞察分析
- 水电站规划与建设-洞察分析
- 水表数据质量监控方法-洞察分析
- 威胁情报可视化技术-洞察分析
- 水暖工程项目管理-洞察分析
- 弦论中的黑洞解-洞察分析
- 2025年国家图书馆招聘笔试参考题库含答案解析
- 机器人课程课程设计
- 人教版五年级上册数学组合图形的面积同步练习
- 学校品牌定义及内涵
- 古诗词1000首
- 2018级成考专升本汉语言文学专业12月份考试资料文献学复习资料
- 最新中考英语单词表2200个
- 我的专业成长故事
- 公司管理制度-公司管理制度
- 井用潜水泵的安装
- 疫情索赔公式及相应表格模板Excel
评论
0/150
提交评论