C语言期中考试题.docx
- 文档编号:5962318
- 上传时间:2023-01-02
- 格式:DOCX
- 页数:7
- 大小:16.86KB
C语言期中考试题.docx
《C语言期中考试题.docx》由会员分享,可在线阅读,更多相关《C语言期中考试题.docx(7页珍藏版)》请在冰豆网上搜索。
C语言期中考试题
Section1:
PutTrue(T)orFalse(F)inthebrackets.
1.InCprogram,uppercaseandlowercaselettersaredistinct.t
2.Allvariablesmustnotbedeclaredbeforeuse.f
3.Thefirstcharacterofvariablesnamemustbealetter.f
4.‘0’equals“0”.f
5.“#defineMAX100”isastatement.f
6.Incomputerterminology,aprogramerroriscalledabug.t
7.InC,functionsmaybenested.t
8.Inputtingdataoraliteralisaconstant.f
9.=+isavalidCoperator.f
Section2:
SingleChoice.
1.AnidentifierD
A.mustbeginwithaletterordigitandcancontainletters,digits,orunderscores
B.mustbeginwithadigitandcancontainletters,digits,orunderscores
C.mustbeginwithaletter,digit,orunderscoreandcancontainletters,digits,orunderscores
D.mustbeginwithaletterorunderscoreandcancontainletters,digits,orunderscores
2.ThefunctionprintfB
A.sendsdatatotheprinterB.sendsdatatothescreen
C.receivesdatafromthekeyboardD.receivesdatafromanyinput
3.ThebasicdatatypesofCareC
A.integer,real,imaginary,doubleB.integer,real,double,character
C.integer,double,float,characterD.character,double,real,float
4.Thevalueof10/9isD
A.1.1B.1.111
C.1.1111D.1
5.AllvariablesmusthaveD
A.AdatatypeandanameB.Anexpressionandaspecifier
C.SyntaxandlogicD.Memorylocationandstatusflag
6.ExpressionscontainingoperatorswiththesameprecedenceareevaluatedaccordingtotheirC
A.orderB.associativity
C.hierarchyD.position
7.AnyexpressionthatisterminatedbyasemicolonisB
A.aconstantB.astatement
C.evaluatedfromlefttorightD.illegalunlessanequalsignispreceding
8.Assumingx=10,theexpression:
x+=15*6changesthevalueofxtoB
A.150B.100
C.900D.90
9.Assumingxis10,whatistheoutput:
printf(“%d”,++x);D
A.8B.9
C.10D.11
10.Whenusingascanffunctiontoinputmultiplevalues,theusermustseparatetheinputwithB
A.commasB.spaces
C.semicolonsD.forwardslashes
11.Assumea=5,b=2,c=4,d=6,ande=5.Whatisthevalueofe%b*c>5||c%d*e>7isB
A.0B.1
C.2D.3
12.Inaswitchstatement,thekeywordbreakB
A.isaccessedifnoneoftheothercasevaluesmatchtheexpression
B.causestheprogramtoexittheswitchstatementcompletely
C.causestheprogramtomovethedefaultcase
D.causestheprogramtoterminate
13.Whatistheoutputfromthefollowingloop:
i=10;
while(i<=10)
printf(“%d\n”,i);B
A.Nooutput
B.Thenumber10willbeoutputinfinitely
C.Thenumber10willbeoutputexactlyonetime
D.Thenumber0through10willbeoutput
14.Whenplacedinawhileloop,thecontinuestatementC
A.CausesthelooptoterminateB.Causestheprogramtoterminate
C.SkipstothenextiterationoftheloopD.Doesnothinginawhileloop
15.ThecomponentsofafunctionheaderincludeD
A.call,returnvalue,prototype
B.argumentlist,parameterlist,call
C.functionbody,functioncall,argumentlist
D.returntype,name,parameterlist
Section3:
Expressioncalculationandfillongblanks.
1.Theitemsenclosedwithintheparenthesesinafunctioncallstatementarecalled________formalparameters__.
2.Thestatementfor(i=1;I<=9;i++)printf(“%3d”,_3i-2__________),thendisplaythefollowingnumbers:
147101316192225.
3.Theprogramthattranslatesahigh-levelsourceprogramasacompleteunitbeforeanyindividualstatementisexecutediscalleda(n)_complier_________.
4.Thevalueofexpression10>=10&&2<=10is___1_______.
5.OnIBM-compatiblecomputers,theEOFmarkisgeneratedwheneverthe___ctrl+c______arepressedsimultaneously.
6.Thefollowingcodefragmentprintsout___3_____
intx,y;
x=y=3;
switch(y)
{
case1:
x=0;
break;
case2:
x=17;
break;
case4:
x=9;
break;
}
Printf(“%d”,x);
7._do-while________statementalwayscreatesaposttestloop.
8.Thesmallestandmostbasicdataiteminacomputerisa__bit______;itisreallyaswitchthatcanbeeitheropen(0)orclosed
(1).
9.Thefollowingcodefragmentprintsout____5_____.
inta=3,b;
if(a>5)
b=7;
elseif(a<2)
b=6;
else
b=5;
printf(“%d”,b);
10.Whenwritingaprogram,a(n)___selection_____structureprovidesthecapabiitytomakeachoicebetweendifferentinstructions,dependingontheresultofsomecondition.
Section4:
Pleaseanswerfollowingquestioninyouranswersheet..
1.WhatisthePhaseofSoftwareDevelopmentProcess?
.
2.AnalysisthefollowingCstructures:
Structure(A)Structure(B)
if(n>0)if(n>0)
if(a>b){
z=a;if(a>b)
elsez=a;
z=b;}
else
z=b;
Pleasedescribethedifferencebetweenstructure(A)and(B).
3.Whatawhileloopthatisequivalenttotheforloopgivenbelow.
For(k=0;k<10;k++)
sum=sum+k;
4.Pleasewritetheoutputofthefollowingstatements.
viodmain()
{
ints=1,t=1,a,n;
scanf(“%d%d”,&a,&n);
for(inti=1;i { t=t*10+1; s=s+t; } s*=a; printf(“SUM=%d\n”,s); } Inputdata: 24 Answer: _____2468_________. 5.Pleasewritetheoutputofthefollowingstatements. intfunc(inta,intb) { staticintm=0,i=2; i+=m+1; m=i+a+b; return(m); } main() { intk=4,m=1,p1,p2; p1=func(k,m); p2=func(k,m); printf(“%d,%d\n”,p1,p2); } Answer: ________8,17__________ 6.Pleasewritetheoutputofthefollowingstatements. intk,s; for(k=1,s=0;k<10;k++) { if(k%2==0)continue; s+=k; } Printf(“k=%ds=%d”,k,s); Answer: _____k=10s=25______________ 7.Pleasewritetheoutputofthefollowingprogram. #include voidmain() { intk,x,s,t; x=3; s=0; t=x; for(k=1;k<=3;k++) { t=t*10+x; s=s+t; printf(“%d#”,s); } } Answer: ___________________. Section5: Programming 1.Writeaninteractiveprogramthataskstheusertoenteramonthnumber(between1and12). Programneedtocheckuserinput: (1).Iftheinputisinvaid,displayerrormessageandpromptuserreenternumber. (2).Iftheinputisvalid,theprogramshoulddispaythemonthnameofinputnumber.(e.g.Inputis“1”,thenoutputis”January”). 2.Findnumbers: thesenumberswhicharesatisfiedwiththefollowingfourconditions: (1).Thenumberisainteger,whichconsistsoffourdigits(between1000and9999); (2).Thefirsttwodigitsaresame; (3).Thelasttwodigitsaresamebutdifferentfromthefirsttwodigits; (4).Thenumberisthesquareofsomeotherintegernumber.
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 语言 期中 考试题