C语言期中考试题Word格式.docx
《C语言期中考试题Word格式.docx》由会员分享,可在线阅读,更多相关《C语言期中考试题Word格式.docx(7页珍藏版)》请在冰豆网上搜索。
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;
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;
b)
elsez=a;
z=b;
}
else
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<
n;
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);
________8,17__________
6.Pleasewritetheoutputofthefollowingstatements.
intk,s;
for(k=1,s=0;
k++)
if(k%2==0)continue;
s+=k;
Printf(“k=%ds=%d”,k,s);
_____k=10s=25______________
7.Pleasewritetheoutputofthefollowingprogram.
#include<
stdio.h>
voidmain()
intk,x,s,t;
x=3;
s=0;
t=x;
for(k=1;
=3;
{
t=t*10+x;
s=s+t;
printf(“%d#”,s);
___________________.
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.