c语言程序设计现代方法(第二版)习题答案

c语言程序设计现代方法(第二版)习题答案

ID:11155078

大小:293.50 KB

页数:83页

时间:2018-07-10

c语言程序设计现代方法(第二版)习题答案_第1页
c语言程序设计现代方法(第二版)习题答案_第2页
c语言程序设计现代方法(第二版)习题答案_第3页
c语言程序设计现代方法(第二版)习题答案_第4页
c语言程序设计现代方法(第二版)习题答案_第5页
资源描述:

《c语言程序设计现代方法(第二版)习题答案》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、Chapter2AnswerstoSelectedExercises2.[was#2](a)Theprogramcontainsonedirective(#include)andfourstatements(threecallsofprintfandonereturn).(b)Parkinson'sLaw:Workexpandssoastofillthetimeavailableforitscompletion.3.[was#4]#includeintmain(void){intheight=8,length=12,width=10,vo

2、lume;volume=height*length*width;printf("Dimensions:%dx%dx%d",length,width,height);printf("Volume(cubicinches):%d",volume);printf("Dimensionalweight(pounds):%d",(volume+165)/166);return0;}4.[was#6]Here'sonepossibleprogram:#includeintmain(void){inti,j,k;floatx,y,z;pri

3、ntf("Valueofi:%d",i);printf("Valueofj:%d",j);printf("Valueofk:%d",k);printf("Valueofx:%g",x);printf("Valueofy:%g",y);printf("Valueofz:%g",z);return0;}WhencompiledusingGCCandthenexecuted,thisprogramproducedthefollowingoutput:Valueofi:5618848Valueofj:0Valueofk:6844404Val

4、ueofx:3.98979e-34Valueofy:9.59105e-39Valueofz:9.59105e-39Thevaluesprinteddependonmanyfactors,sothechancethatyou'llgetexactlythesenumbersissmall.5.[was#10](a)isnotlegalbecause100_bottlesbeginswithadigit.8.[was#12]Thereare14tokens:a,=,(,3,*,q,-,p,*,p,),/,3,and;.AnswerstoSelectedProg

5、rammingProjects4.[was#8;modified]#includeintmain(void){floatoriginal_amount,amount_with_tax;printf("Enteranamount:");scanf("%f",&original_amount);amount_with_tax=original_amount*1.05f;printf("Withtaxadded:$%.2f",amount_with_tax);return0;}Theamount_with_taxvariableisunne

6、cessary.Ifweremoveit,theprogramisslightlyshorter:#includeintmain(void){floatoriginal_amount;printf("Enteranamount:");scanf("%f",&original_amount);printf("Withtaxadded:$%.2f",original_amount*1.05f);return0;}Chapter3AnswerstoSelectedExercises2.[was#2](a)printf("%-8.1e",x)

7、;(b)printf("%10.6e",x);(c)printf("%-8.3f",x);(d)printf("%6.0f",x);5.[was#8]Thevaluesofx,i,andywillbe12.3,45,and.6,respectively.AnswerstoSelectedProgrammingProjects1.[was#4;modified]#includeintmain(void){intmonth,day,year;printf("Enteradate(mm/dd/yyyy):");scanf("%d/%d/%d",

8、&month,&day,&year);printf("Youent

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

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

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