Whichofthefollowingis(are)trueregardingexecutionofthesegment?
Theinputstatementwillalwaystakethesameamountoftimetoexecute.
Theoutputstatementwillalwaysbeexecutedimmediatelyaftertheinputstatement.
Ifxandyarebothpositive,anintegergreaterthanbothwillbeprinted.
(a)IIonly(b)none(c)IandIIonly(d)IIandIIIonly
Correctansweris(b)Seesection1.1.1ofthecoursenotes.
--------------------------------------------------------------------------------
2.Integratedprogrammingenvironmentsmakeitdifficulttomixandmatchtoolsfromdifferentsources.Thisis
(a)bad,becausenosinglevendorislikelytobethesourceofallthebesttools
(b)good,becauseitensurescompilationisnotdoneincrementallybyaccident
(c)bad,becauseallthetoolswillthenhavethesameuserinterface
(d)good,becausetoolsfromdifferentsourcescannotbemadetointeractwitheachother
Correctansweris(a)Seesection1.1.4ofthecoursenotes.
--------------------------------------------------------------------------------
3.InVisualC++,aWin32ConsoleApplicationis
(a)aprogramthatisabletocontroltheoperatingsystemofawindowscomputer
(b)thesimplesttypeofapplicationVisualC++cangenerate
(c)thestatuswindowoftheVisualC++environment
(d)builtbyusingsophisticated"ApplicationWizards"
Correctansweris(b)Seesection1.2.1ofthecoursenotes.
4.WhichofthefollowingmustbetrueifaprogramisstoppedataspecificlinewithintheVisualC++debugger?
Thereisatleastonebreakpointenabled.
Thereisabreakpointenabledonthatline.
Thereisabreakpointenabledonthelineprecedingthatline.
(a)IandIIIonly(b)IandIIonly(c)none(d)Ionly
Correctansweris(c)
5.Whatdoesthefollowingprogramprint?
voidcallee(int*count){
(*count)++;
}
intmain(intargc,char*argv[]){
intcount=4;
callee(count);
printf("%d",count);
return0;
}
(a)8(b)nothing:
itwillnotcompilesuccessfully
(c)4(d)5
Correctansweris(b)Seesection1.4.1ofthecoursenotes.
6.Considerthefollowingprogram.
inti;
int*jp=&i;
intmain(inti,char*argv[]){
printf("%d%d\n",(int)&i,(int)jp);//随机值i,与局部值i不一样
}
Whichofthefollowingdescribeswhatitprints?
(a)twovalues,one4greaterthantheother
(b)twoverydifferentintegers
(c)nothing:
itwillnotcompilebecauseitisambiguous
(d)twointegersthatareexactlythesame
Correctansweris(b)
--------------------------------------------------------------------------------
xxx7.Activationrecordsareorganizedinstacksbecause
(a)stacksallowactivationrecordstobepushedandpoppedinanyorder.
(b)functionsneedtoaccessallthevariablesofthefunctionsthatcallthem.
(c)theyareseldomneededduringprogramexecution.
(d)stacksaresimpleenoughforthehardwaretomanage.
Correctansweris(d)
8.Whatdoesthefollowingprogramprint?
intcallee(int*count){
count++;
return*count;
}
intmain(intargc,char*argv[]){
intcount=4;
intretval;
retval=callee(&count);
printf("%d",retval);
return0;
}(a)5(b)cannotbedeterminedfromtheinformationgiven.
(c)4(d)8
Correctansweris(b)
9.ConsiderthefollowingsegmentofCsourcecode.
inta=8;
intb=*&a;
Whatisthevalueofvariablebattheendofexecutionofthesegment?
(a)(int)&b(b)&a
(c)(int)&a(d)a
Correctansweris(d)
xxx10.ConsiderthefollowingsegmentofaCprogram.
inti=99;
inta[100];
i=a[i+1];
Whichofthefollowingistrueofthesegment?
(a)Whenexecuted,theprogramwillbeprematurelyterminatedbytheoperatingsystembecauseofanillegalmemoryaccess.
(b)iwillhavethevalueofthelastelementofthearrayaattheendofanyexecutionofthesegment.
(c)Executionwillfailbecauseahasthewrongsize.
(d)iwillhavethevalue99attheendofanyexecutionofthesegment.
Correctansweris(d)
xxx11.Abranchinstruction
(a)setstheprogramcountertooneoftwopossiblevalues
(b)setstheprogramcountertooneofmanypossiblevalues
(c)increasestheprogramcounterbyafixedamount
(d)unconditionallysetstheprogramcountertoitsoperand
Correctansweris(a)
xxx12.Whichofthefollowingisagoodreason(aregoodreasons)toequiptheCPUwithsmallamountsoffastmemory?
//这里指CPU里的寄存器
Tomakethedesignofthecompilersimpler
TomakesomeCPUinstructionssmaller
TomakesomeCPUinstructionsfaster
(a)IIIonly
(b)IIandIIIonly
(c)I,II,andIII
(d)IIonly
Correctansweris(b)
13.Supposethat,usingatoolsuchasthememorywindowofVisualC++,wefoundthatacertainsetofcontiguousmemorylocationscontainedtheinteger0xC605CD623A8365000000.Whatcouldthesememorylocationshold?
theinteger0xC605CD623A8365000000
astring
aCPUinstruction
(a)I,II,andIII
(b)IIIonly
(c)IandIIonly
(d)IonlyCorrectansweris(a)
14.WhichofthefollowingcomputationsmaybeperformedbyexactlyoneCPUinstruction?
a=5;//直接用MOV语句就可以了
a=b+c*5;
for(i=0;i<10;i+=a[i++]);
(a)IandIIonly
(b)Ionly
(c)I,II,andIII
(d)IIonlyCorrectansweris(b)
1.WhichofthefollowingVisualC++objectsarecontainedwithina"Project"?
Files
VisualC++Solutions
Flowcharts
(a)IIandIIIonly
(b)IIonly
(c)I,IIandIII
(d)Ionly
Correctansweris(d)
xxx2.Whichofthefollowingdoesadebuggerdo?
//debug状态程序语法没错,语义有错,要程序员自己调出来
Analyzethesourcecodetofindprogrammingerrors.
Decodemachinecodegeneratedbyacompiler.
Stopexecutionofaprogram.
(a)IIandIIIonly
(b)IandIIIonly
(c)I,II,andIII.
(d)IIIonlyCorrectansweris(a)
--------------------------------------------------------------------------------
4.WithinVisualC++,whichofthefollowingwillrevealthevalueofavariablewhentheprogramisstoppedatabreakpoint?
Placingthemousepointeroverthevariablenameinthesourcefilewindow.
Insertingaprintf()intheprogram.
Typingthevariablenameonthe"Watch"window.
(a)IandIIIonly
(b)IIIonly
(c)IIandIIIonly
(d)I,II,andIII
Correctansweris(a)
--------------------------------------------------------------------------------
xxx6.Atwhichofthefollowingtimesisanactivationrecordcreated?
Whenaprogramstartsexecuting.
Everytimeafunctionisinvoked.
Whenavariableisdeclared.
(a)IIandIIIonly
(b)IIIonly
(c)IandIIonly
(d)IIonly
Correctansweris(c)
-----------------------------------------------------------------------------
xxx8.Considertheprogramgivenbelow.
#include
intcallee(void){
intcount=5;
printf("%d",(int)&count);
returncount;
}
intmain(intargc,char*argv[]){
intcount=4;
count=callee();
printf("%d",(int)&count);
return0;
}
Whichofthefollowingdescribestheoutputoftheprogram?
(a)5and4areprinted,inthatorderonthesameline.
(b)Oneintegerisprintedtwice,anditsvaluecannotbedeterminedfromtheinformationgiven.
(c)5isprintedtwiceonthesameline.
(d)Twodifferentintegersareprinted,andthevalueofneithercanbedeterminedfromtheinformationgiven.
Correctansweris(d)
--------------------------------------------------------------------------------
9.Inacomputerinwhichbothaddressesandintegersare32bitswide,howmanybytesofmemorywillthecompilerallocateasaresultofthefollowingpointerdeclaration?
int*pointer;
(a)0
(b)8
(c)4
(d)64
Correctansweris(c)
--------------------------------------------------------------------------------
xxx11.Theprogramcountercontains
(a)thenumberofCPUinstructionsaprogramhasexecutedsofar
(b)theamountofmemoryaprogramiscurrentlyusing
(c)thenumberoftimesaprogramhasbeenexecuted
(d)theaddressoftheCPUinstructionthatisabouttobeexecuted
Correctansweris(d)
--------------------------------------------------------------------------------
xxx12.Ajumpinstruction
(a)unconditionallysetstheprogramcountertoitsoperand
(b)increasestheprogramcounter
(c)changesapointertopointtothenextelementofanarray
(d)changestheprogramcounteronlyifitsoperandisequaltozero
Correctansweris(a)
--------------------------------------------------------------------------------
xxx13.Wewantthevariablefactorialfunctoholdtheaddressofthefirstinstructionofthefollowingfunction:
intfactorial(intn){
if(n==1)returnn;
returnn*factorial(n-1);
}
Howwouldwedeclarethevariable?
(a)int(*factorialfunc)(int);
(b)wecan't:
Ccannotextracttheaddressesofinstructions.
(c)int(int)*factorialfunc
(d)factorial()*factorialfunc;
Correctansweris(a)
--------------------------------------------------------------------------------
xxx2.Whichofthefollowingisabletodescribeacomputationatthehighestlevelofabstraction?
(a)C++code
(b)Ccode
(c)logicGates
(d)machinecode
Correctansweris(a)
--------------------------------------------------------------------------------
4.WhendebuggingusingVisualC++,whichofthefollowingarepossiblethroughtheWatchwindow?
Theprogram'sexecutioncanbestopped.//不能通过watch窗口将程序暂停
ThevalueofanarbitraryCexpressioncanbecalculated.
Thevalueofaprogramvariablecanbeset.
(a)IIIonly
(b)IIonly
(c)IIandIIIonly
(d)I,II,andIII.Correctanswer