文档介绍:精品资料,欢迎大家下载!
以上资料仅供参考,如有侵权,留言第一时间删除!
C语言全部题目与答案Exercise1:ProgrammingEnvironmentandBasicInput/:
Interestcalculationprogram.
Startingbalance?6000Annualinterestratepercentage?
Balanceafteroneyear6255ANSWER:
#include<>intmain(){floatnet_price,sales_tax,total;net_price=889;sales_tax=net_price*;total=net_price+sales_tax;printf("Thetotalpurchasepriceis%g",total);return0;}#include<>intmain(){printf("Pleaseinputanumberasradius:\n");floatradius,diameter,circumference,area;scanf("%f',&radius);printf("Thediameteris%g\n",diameter=radius*2);printf("Thecircumferenceis%g\n",circumference=radius*2*);printf("Theareais%g\n",area=radius*radius*);return0;}#include<>intmain(){floatSB,percentage,NB;printf("Interestcalculationprogram\n\nPleaseentertheStartingBalance:");scanf("%f',&SB);printf("PleaseentertheAnnualinterestratepercentage:");scanf("%f',&percentage);NB=SB*percentage/100+SB;printf("\nTheBalanceafteroneyearis:%g",NB);return0;}Exercise
精品资料,欢迎大家下载!
以上资料仅供参考,如有侵权,留言第一时间删除!
3:SelectionstructureWriteaCprogramthatacceptsastudent'snumericalgrade,convertsthenumericalgradetoPassed(gradeisbetween60-100),Failed(gradeisbetween0-59),orError(gradeislessthan0orgreaterthan100).
Writeaprogramthataskstheusertoenteranintegernumber,thentellstheuserwhetheritisanoddorevennumber.
Writeaprogramthatreadsinthreeintegersandthendeterminesandprintsthelargestinthegroup.
ANSWER:#include<>#include<>intmain(){intgrade;printf("Pleaseenterthegrade:");scanf("%d",&grade);if(grade>=60&&grade<=100)printf("Passed.");elseif(grade>=0&&grade<60)printf("Failed.");elseprintf("Error.〞);return0;}
#include<>intmain(){
inta,b,c;
printf("Pleaseenter3integernumbers\n");
printf("ThenI'lltellyouwhichisthelargest\n");
scanf(