C语言程序设计_现代方法_答案

C语言程序设计_现代方法_答案

ID:39876115

大小:177.09 KB

页数:78页

时间:2019-07-13

C语言程序设计_现代方法_答案_第1页
C语言程序设计_现代方法_答案_第2页
C语言程序设计_现代方法_答案_第3页
C语言程序设计_现代方法_答案_第4页
C语言程序设计_现代方法_答案_第5页
资源描述:

《C语言程序设计_现代方法_答案》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、AnswerstoSelectedExercisesandProgrammingProjectsThefollowinglinksleadtoanswerstoselectedexercisesandprogrammingprojectsfromthesecondeditionofCProgramming:AModernApproach.Exercisesandprojectsforwhichanswersareprovidedaremarkedwithaiconinthebook.Note:Theseexercisesandprojectswereorigina

2、llytheeven-numberedexercisesinthefirstedition.(Thefirsteditiondidnotdistinguishbetweenexercisesandprogrammingprojects.)Forthebenefitofreaderswhohavethefirstedition,theoriginalexercisenumberisgiveninsquarebrackets.Forexample,thenotation[was#4]indicatesthatthenumberoftheexercise(orprogr

3、ammingproject)was4inthefirstedition.Ifananswerisdifferentbecauseofsecond-editionchanges,theword"modified"willappearinsidethebrackets:[was#4;modified].Pleaseemailmewithcommentsanderrorreports.Chapter2AnswerstoSelectedExercises2.[was#2](a)Theprogramcontainsonedirective(#include)andfours

4、tatements(threecallsofprintfandonereturn).(b)Parkinson'sLaw:Workexpandssoastofillthetimeavailableforitscompletion.3.[was#4]#includeintmain(void){intheight=8,length=12,width=10,volume;volume=height*length*width;printf("Dimensions:%dx%dx%d",length,width,height);printf("Volume

5、(cubicinches):%d",volume);printf("Dimensionalweight(pounds):%d",(volume+165)/166);return0;}4.[was#6]Here'sonepossibleprogram:#includeintmain(void){inti,j,k;floatx,y,z;printf("Valueofi:%d",i);printf("Valueofj:%d",j);printf("Valueofk:%d",k);printf("Valueofx:%g",x);p

6、rintf("Valueofy:%g",y);printf("Valueofz:%g",z);return0;}WhencompiledusingGCCandthenexecuted,thisprogramproducedthefollowingoutput:Valueofi:5618848Valueofj:0Valueofk:6844404Valueofx:3.98979e-34Valueofy:9.59105e-39Valueofz:9.59105e-39Thevaluesprinteddependonmanyfactors,sothechanceth

7、atyou'llgetexactlythesenumbersissmall.5.[was#10](a)isnotlegalbecause100_bottlesbeginswithadigit.8.[was#12]Thereare14tokens:a,=,(,3,*,q,-,p,*,p,),/,3,and;.AnswerstoSelectedProgrammingProjects4.[was#8;modified]#includeintmain(void){floatoriginal_amount,amount_with_tax;printf("E

8、ntera

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。