欢迎来到天天文库
浏览记录
ID:26765597
大小:71.12 KB
页数:73页
时间:2018-11-29
《cprimerplus第6版编程练习答案解析[已]》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、WORD完美格式编辑Chapter2ProgrammingExercisesPE2-‐1/*ProgrammingExercise2-1*/#includeintmain(void){printf("GustavMahler");printf("GustavMahler");printf("Gustav");printf("Mahler");return0;}PE2-‐3/*ProgrammingExercise2-3*/#includeintmain(void){intageyears;/*ageinyears*/i
2、ntagedays;/*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;}v
3、oidjolly(void){printf("Forhe'sajollygoodfellow!");}voiddeny(void){printf("Whichnobodycandeny!");}PE2-‐6/*ProgrammingExercise2-6*/#includeintmain(void){inttoes;toes=10;printf("toes=%d",toes);专业资料整理WORD完美格式编辑printf("Twicetoes=%d",2*toes);printf("toessquared=%d",toes*toes
4、);return0;}/*orcreatetwomorevariables,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");
5、}voidtwo(void){printf("two");}Chapter3ProgrammingExercisesPE3-‐2/*ProgrammingExercise3-2*/#includeintmain(void){intascii;printf("EnteranASCIIcode:");scanf("%d",&ascii);printf("%distheASCIIcodefor%c.",ascii,ascii);return0;}PE3-‐4/*ProgrammingExercise3-4*/#includeintm
6、ain(void){floatnum;printf("Enterafloating-pointvalue:");scanf("%f",&num);printf("fixed-pointnotation:%f",num);printf("exponentialnotation:%e",num);printf("pnotation:%a",num);return0;}专业资料整理WORD完美格式编辑PE3-‐6/*ProgrammingExercise3-6*/#includeintmain(void){floatmass_mol=3.0e-2
7、3;/*massofwatermoleculeingrams*/floatmass_qt=950;/*massofquartofwateringrams*/floatquarts;floatmolecules;printf("Enterthenumberofquartsofwater:");scanf("%f",&quarts);molecules=quarts*mass_qt/mass_mol;printf("%fquartsofwatercontain%emolecules.",quarts,molecules);return0;
此文档下载收益归作者所有