欢迎来到天天文库
浏览记录
ID:47192768
大小:70.05 KB
页数:73页
时间:2019-08-19
《CPrimerPlus第6版编程练习答案解析(已下载)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
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;/*a
2、geindays*//*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){p
3、rintf("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;}/*orcreatetwomorevariabl
4、es,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");}Chapte
5、r3ProgrammingExercisesPE3-‐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("Enterafloating
6、-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;/*massofqua
7、rtofwateringrams*/floatquarts;floatmolecules;printf("Enterthenumberofquartsofwater:");scanf("%f",&quarts);molecules=quarts*mass_qt/mass_mol;printf("%fquartsofwatercontain%emolecules.",quarts,molecules);return0;}Chapter4ProgrammingExercisesPE4-‐1/*Progr
此文档下载收益归作者所有