the_c_programming_language习题答案解析.pdf

the_c_programming_language习题答案解析.pdf

ID:51096311

大小:845.23 KB

页数:327页

时间:2020-03-19

the_c_programming_language习题答案解析.pdf_第1页
the_c_programming_language习题答案解析.pdf_第2页
the_c_programming_language习题答案解析.pdf_第3页
the_c_programming_language习题答案解析.pdf_第4页
the_c_programming_language习题答案解析.pdf_第5页
资源描述:

《the_c_programming_language习题答案解析.pdf》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、"TheCProgrammingLanguage",2ndedition,KernighanandRitchieAnswertoExercise1-1Runthe"hello,world"programonyoursystem.Experimentwithleavingoutpartsoftheprogram,toseewhaterrormessagesyouget.Murphy'sLawdictatesthatthereisnosinglecorrectanswertotheveryfirstexerciseinth

2、ebook.Ohwell.Here'sa"helloworld"program:#includeintmain(void){printf("hello,world");return0;}Asyoucansee,I'veaddedareturnstatement,becausemainalwaysreturnsint,andit'sgoodstyletoshowthisexplicitly.AnswertoExercise1-2Experimenttofindoutwhathappenswhenpr

3、intf'sargumentstringcontainsc,wherecissomecharacternotlistedabove.By'above',thequestionisreferringto:(newline)t(tab)b(backspace)"(doublequote)\(backslash)Wehavetotreadcarefullyhere,becauseusinganon-specifiedescapesequenceinvokesundefinedbehaviour.Thefollo

4、wingprogramattemptstodemonstrateallthelegalescapesequences,notincludingtheonesalreadyshown(except,whichIactuallyneedintheprogram),andnotincludinghexadecimalandoctalescapesequences.#includeintmain(void){printf("Audibleorvisualalert.a");printf("Formf

5、eed.f");printf("Thisescape,r,movestheactivepositiontotheinitialpositionofthecurrentline.");printf("Verticaltabvistricky,asitsbehaviourisunspecifiedundercertainconditions.");return0;}AnswertoExercise1-3Modifythetemperatureconversionprogramtoprintaheading

6、abovethetable.#includeintmain(void){floatfahr,celsius;intlower,upper,step;lower=0;upper=300;step=20;printf("FC");fahr=lower;while(fahr<=upper){celsius=(5.0/9.0)*(fahr-32.0);printf("%3.0f%6.1f",fahr,celsius);fahr=fahr+step;}return0;}AnswertoExercis

7、e1-4WriteaprogramtoprintthecorrespondingCelsiustoFahrenheittable.#includeintmain(void){floatfahr,celsius;intlower,upper,step;lower=0;upper=300;step=20;printf("CF");celsius=lower;while(celsius<=upper){fahr=(9.0/5.0)*celsius+32.0;printf("%3.0f%6.1f"

8、,celsius,fahr);celsius=celsius+step;}return0;}AnswertoExercise1-5Modifythetemperatureconversionprogramtoprintthetableinreverseorder,thatis,from300degreesto0.Thisversi

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

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

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