欢迎来到天天文库
浏览记录
ID:48196921
大小:72.22 KB
页数:96页
时间:2020-01-22
《C_Primer_Plus第6版编程练习答案(已下载).doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、........Chapter2ProgrammingExercisesPE2-‐1/*ProgrammingExercise2-1*/#includeintmain(void){printf("GustavMahler");printf("GustavMahler");printf("Gustav");printf("Mahler");return0;}PE2-‐3/*ProgrammingExercise2-3*/#includeintmain(void){intageyears;/*ageinyears*/intagedays;
2、/*ageindays*//*largeagesmayrequirethelongtype*/ageyears=101;agedays=365*ageyears;printf("Anageof%dyearsis%ddays.",ageyears,agedays);return0;}PE2-‐4/*ProgrammingExercise2-4*/#includevoidjolly(void);voiddeny(void);intmain(void){jolly();jolly();jolly();deny();return0;}voidjolly(void){pri
3、ntf("Forhe'sajollygoodfellow!");}.学习参考.........voiddeny(void){printf("Whichnobodycandeny!");}PE2-‐6/*ProgrammingExercise2-6*/#includeintmain(void){inttoes;toes=10;printf("toes=%d",toes);printf("Twicetoes=%d",2*toes);printf("toessquared=%d",toes*toes);return0;}/*orcreatetwomore
4、variables,setthemto2*toesandtoes*toes*/PE2-‐8/*ProgrammingExercise2-8*/#includevoidone_three(void);voidtwo(void);intmain(void){printf("startingnow:");one_three();printf("done!");return0;}voidone_three(void){printf("one");two();printf("three");}voidtwo(void){printf("two");}.学习参
5、考.........Chapter3ProgrammingExercisesPE3-‐2/*ProgrammingExercise3-2*/#includeintmain(void){intascii;printf("EnteranASCIIcode:");scanf("%d",&ascii);printf("%distheASCIIcodefor%c.",ascii,ascii);return0;}PE3-‐4/*ProgrammingExercise3-4*/#includeintmain(void){floatnum;printf("Ent
6、erafloating-pointvalue:");scanf("%f",&num);printf("fixed-pointnotation:%f",num);printf("exponentialnotation:%e",num);printf("pnotation:%a",num);return0;}PE3-‐6/*ProgrammingExercise3-6*/#includeintmain(void){floatmass_mol=3.0e-23;/*massofwatermoleculeingrams*/floatmass_qt=950;/*mas
7、sofquartofwateringrams*/floatquarts;floatmolecules;printf("Enterthenumberofquartsofwater:");scanf("%f",&quarts);molecules=quarts*mass_qt/mass_mol;printf("%fquartsofwatercontain%emolecules.",quarts,molecules);return0;}.学习参考
此文档下载收益归作者所有