C语言程序设计内容_现代方法_答案.pdf

C语言程序设计内容_现代方法_答案.pdf

ID:52430021

大小:177.09 KB

页数:78页

时间:2020-03-27

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

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

1、AnswerstoSelectedExercisesandProgrammingProjectsThefollowinglinksleadtoanswerstoselectedexercisesandprogrammingprojectsfromthesecondeditionofCProgramming:AModernApproach.Exercisesandprojectsforwhichanswersareprovidedaremarkedwithaiconinthebook.Note:Theseexercisesandprojectswereoriginallytheeven-nu

2、mberedexercisesinthefirstedition.(Thefirsteditiondidnotdistinguishbetweenexercisesandprogrammingprojects.)Forthebenefitofreaderswhohavethefirstedition,theoriginalexercisenumberisgiveninsquarebrackets.Forexample,thenotation[was#4]indicatesthatthenumberoftheexercise(orprogrammingproject)was4inthefir

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

4、n).(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(cubicinches):%d",volume);printf("Dimensionalweigh

5、t(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);printf("Valueofy:%g",y);printf("Valueofz:%g",z);return0;}Whenc

6、ompiledusingGCCandthenexecuted,thisprogramproducedthefollowingoutput:Valueofi:5618848Valueofj:0Valueofk:6844404Valueofx:3.98979e-34Valueofy:9.59105e-39Valueofz:9.59105e-39Thevaluesprinteddependonmanyfactors,sothechancethatyou'llgetexactlythesenumbersissmall.5.[was#10](a)isnotlegalbecause100_bottle

7、sbeginswithadigit.8.[was#12]Thereare14tokens:a,=,(,3,*,q,-,p,*,p,),/,3,and;.AnswerstoSelectedProgrammingProjects4.[was#8;modified]#includeintmain(void){floatoriginal_amount,amount_with_tax;printf("Entera

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

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

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