CPrimerPlusSixthEditionProgrammingExerciseSelectedAnswers1Chapter2ProgrammingExercisesPE2-1/*ProgrammingExercise2-1*/#includestdio.hintmain(void){printf(GustavMahler\n);printf(Gustav\nMahler\n);printf(Gustav);printf(Mahler\n);return0;}PE2-3/*ProgrammingExercise2-3*/#includestdio.hintmain(void){intageyears;/*ageinyears*/intagedays;/*ageindays*//*largeagesmayrequirethelongtype*/ageyears=101;agedays=365*ageyears;printf(Anageof%dyearsis%ddays.\n,ageyears,agedays);return0;}PE2-4/*ProgrammingExercise2-4*/#includestdio.hvoidjolly(void);voiddeny(void);intmain(void){jolly();jolly();jolly();deny();return0;}voidjolly(void){printf(Forhe'sajollygoodfellow!\n);}voiddeny(void){printf(Whichnobodycandeny!\n);}PE2-6/*ProgrammingExercise2-6*/#includestdio.hintmain(void){inttoes;toes=10;printf(toes=%d\n,toes);CPrimerPlusSixthEditionProgrammingExerciseSelectedAnswers2printf(Twicetoes=%d\n,2*toes);printf(toessquared=%d\n,toes*toes);return0;}/*orcreatetwomorevariables,setthemto2*toesandtoes*toes*/PE2-8/*ProgrammingExercise2-8*/#includestdio.hvoidone_three(void);voidtwo(void);intmain(void){printf(startingnow:\n);one_three();printf(done!\n);return0;}voidone_three(void){printf(one\n);two();printf(three\n);}voidtwo(void){printf(two\n);}Chapter3ProgrammingExercisesPE3-2/*ProgrammingExercise3-2*/#includestdio.hintmain(void){intascii;printf(EnteranASCIIcode:);scanf(%d,&ascii);printf(%distheASCIIcodefor%c.\n,ascii,ascii);return0;}PE3-4/*ProgrammingExercise3-4*/#includestdio.hintmain(void){floatnum;printf(Enterafloating-pointvalue:);scanf(%f,&num);printf(fixed-pointnotation:%f\n,num);printf(exponentialnotation:%e\n,num);printf(pnotation:%a\n,num);return0;}CPrimerPlusSixthEditionProgrammingExerciseSelectedAnswers3PE3-6/*ProgrammingExercise3-6*/#includestdio.hintmain(void){floatmass_mol=3.0e-23;/*massofwatermoleculeingrams*/floatmass_qt=950;/*massofquartofwateringrams*/floatquarts;floatmolecules;printf(Enterthenumberofquartsofwater:);scanf(%f,&quarts);molecules=quarts*mass_qt/mass_mol;printf(%fquartsofwatercontain%emolecules.\n,quarts,molecules);return0;}Chapter4ProgrammingExercisesPE4-1/*ProgrammingExercise4-1*/#includestdio.hintmain(void){charfname[40];charlname[40];printf(Enteryourfirstname:);scanf(%s,fname);printf(Enteryourlastname:);scanf(%s,lname);printf(%s,%s\n,lname,fname);return0;}PE4-4/*ProgrammingExercise4-4*/#includestdio.hintmain(void){floatheight;charname[40];printf(Enteryourheightininches:);scanf(%f,&height);printf(Enteryourname:);scanf(%s,name);printf(%s,youare%.3ffeettall\n,name,height/12.0);return0;}PE4-7/*ProgrammingExercise4-7*/#includestdio.h#includefloat.hintmain(void)CPrimerPlusSixthEditionProgrammingExerciseSelectedAnswers4{floatot_f=1.0/3.0;doubleot_d=1.0/3.0;printf(floatvalues:);printf(%.4f%.12f%.16f\n,ot_f,ot_f,ot_f);printf(doublevalues:);printf(%.4f%.12f%.16f\n,ot_d,ot_d,ot_d);printf(FLT_DIG:%d\n,FLT_DIG);printf(DBL_DIG:%d\n,DBL_DIG);return0;}Chapter5ProgrammingExercisesPE5-1/*ProgrammingExercise5-1*/#includestdio.hintmain(void){constintminperhour=60;intminutes,hours,mins;printf(Enterthenumberofminutestoconvert:);scanf(%d,&minutes);while(minutes0){hours=minutes/minperhour;mins=minutes%minperhour;printf(%dminutes=%dhours,%dminutes\n,minutes,hours,mins);printf(Enternextminutesvalue(0toquit):);scanf(%d,&minutes);}printf(Bye\n);return0;}PE5-3/*ProgrammingExercise5-3*/#includestdio.hintmain(void){constintdaysperweek=7;intdays,weeks,day_rem;printf(Enterthenumberofdays:);scanf(%d,&days);while(days0){weeks=days/daysperweek;day_rem=days%daysperweek;printf(%ddaysare%dweeksand%ddays.\n,days,weeks,day_rem);printf(Enterthenumberofdays(0orlesstoend):);scanf(%d,&days);}printf(Done!\n);return0;CPrimerPlusSixthEditionProgrammingExerciseSelectedAnswers5}PE5-5/*ProgrammingExercise5-5*/#includestdio.hintmain(void)/*findssumoffirstnintegers*/{intcount,sum;intn;printf(Entertheupperlimit:);scanf(%d,&n);count=0;sum=0;while(count++n)sum=sum+count;printf(sum=%d\n,sum);return0;}PE5-7/*ProgrammingExercise5-7*/#includestdio.hvoidshowCube(doublex);intmain(void)/*findscubeofenterednumber*/{doubleval;printf(Enterafloating-pointvalue:);scanf(%lf,&val);showCube(val);return0;}voidshowCube(doublex){printf(Thecubeof%eis%e.\n,x,x*x*x);}Chapter6ProgrammingExercisesPE6-1/*pe6-1.c*//*thisimplementationassumesthecharactercodes*//*aresequential,astheyareinASCII.*/#includestdio.h#defineSIZE26intmain(void){charlcase[SIZE];inti;for(i=0;iSIZE;i++)lcase[i]='a'+i;for(i=0;iSIZE;i++)printf(%c,lcase[i]);printf(\n);return0;}PE6-3/*pe6-3.c*//*thisimplementationassumesthecharactercodes*//*aresequential,astheyareinASCII.*/CPrimerPlusSixthEditionProgrammingExerciseSelectedAnswers6#includestdio.hintmain(void){charlet='F';charstart;charend;for(end=let;end='A';end--){for(start=let;start=end;start--)printf(%c,start);printf(\n);}return0;}PE6-6/*pe6-6.c*/#includestdio.hintmain(void){intlower,upper,index;intsquare,cube;printf(Enterstartinginteger:);scanf(%d,&lower);printf(Enterendinginteger:);sca