Whichofthefollowingis(are)trueregardingexecutionofthesegment?
1.Theinputstatementwillalwaystakethesameamountoftimetoexecute.
2.Theoutputstatementwillalwaysbeexecutedimmediatelyaftertheinputstatement.
3.Ifxandyarebothpositive,anintegergreaterthanbothwillbeprinted.
a.IIandIIIonly
b.IandIIonly
c.none
d.IIonly
5.Integratedprogrammingenvironmentsmakeitdifficulttomixandmatchtoolsfromdifferentsources.Thisis(b)
a.good,becausetoolsfromdifferentsourcescannotbemadetointeractwitheachother
b.bad,becausenosinglevendorislikelytobethesourceofallthebesttools
c.bad,becauseallthetoolswillthenhavethesameuserinterface
d.good,becauseitensurescompilationisnotdoneincrementallybyaccident
6.Comparedtoasequenceofmachinecodeinstructions,afragmentofCcode(a)
a.maydescribethesamealgorithm
b.isthenativewaytoprogrammostcomputers
c.describestheactionsofthecomputer,notjustoftheCPU
d.doesnotengageanytransistorsduringitsexecution
7.Whichofthefollowingdoesadebuggerdo?
(c)
1.Analyzethesourcecodetofindprogrammingerrors.
2.Decodemachinecodegeneratedbyacompiler.
3.Stopexecutionofaprogram.
a.I,II,andIII.
b.IandIIIonly
c.IIandIIIonly
d.IIIonly
8.Whenusingadebuggertofindthecauseofaprogram'sincorrectbehavior,(a)
a.itisoftennecessarytostarttheprogrammultipletimesunderthedebugger
b.thefaultycodefragmentmustfirstbeidentified
c.theprogramisusuallyexecutedtothepointatwhichthebehavioroccursandthenexecutedbackwardstofindthecause
d.itisfastesttostartbystoppingthedebuggerlongbeforethebehaviorappears
MultipleChoiceQuiz2
1.Inacomputerwith4-bytewords,whichofthefollowingCexpressionstestswhetherptrcontainstheaddressofaword?
(c)
I.(ptr&3)==0
II.(ptr|3)==0
III.(ptr%4)==0
a.IIIonly
b.Ionly
c.IandIIIonly
d.IIonly
2.WhathappensinaCprogramwhenanadditionwouldcauseintegeroverflow?
(a)
a.Anincorrectresultisproducedandexecutioncontinues.
b.Anexception-handleriscalledwiththetwooperandsasparameters.
c.Executionisterminated.
d.Thecorrectvalueiscoercedtoafloatingpointnumber.
3.InC,whatisthefollowingbinarynumberinhexadecimal?
(a)
11010101
a.0xD5
b.0x5D
c.0xB5
d.0xAB
4.Whatisthepurposeoftheexponentinfloatingpointnumbers?
(c)
a.tospecifythebaseasbinary,octal,orhexadecimal
b.themantissaisraisedtothepoweroftheexponent
c.toindicatewherethedecimalorbinarypointshouldbe
d.tospecifythesuperscript
5.Howis-10(decimal)representedinan8-bit2'scomplementbinaryformat?
(a)
a.11110110
b.11110101
c.10001010
d.11111010
6.InC,usingdefaultfloatingpointsettings,whathappenswhenafloating-pointcomputationresultsinanoverflow?
(c)
a.Anerroneousvalueiscomputedandexecutioncontinues.
b.Programexecutionishalted.
c.Aspecialvalue"infinity"iscomputed,testablewith_finite().
d.Anexceptionisraisedunlessdisabledbycalling_controlfp().
7.WhatisthevalueofthefollowingCexpression?
(c)
0x1234&0x5432
a.0x1111
b.0x6666
c.0x1030
d.0x5636
8.Whichofthefollowingnumericaloperationsismostlikelytoleadtolossofprecision?
(c)
a.Floating-pointmultiplication
b.Integeraddition
c.Floating-pointaddition
d.Integermultiplication
9.Whichofthefollowingcouldberepresentedbyonebitofinformation?
(c)
a.thecolorofasinglepixelonatrue-colorcomputerdisplay
b.anASCIIcharacter
c.thepositionofalightswitch
d.thecurrentchannelofatelevisionreceiver
10.Whichofthefollowingstatementsaboutfloating-pointnumbersinCistrue?
(a)
I.Floating-pointnumbersareoftenonlyapproximationsofrealnumbers.
II.A32-bitfloatonlyapproximatesdecimalfractions,buta64-bitdoublerepresentsthemexactly.
III.Floating-pointnumberscanrepresentanyrationalrealnumberbutnotirrationals.
a.Ionly
b.IandIIIonly
c.IIonly
d.IandIIonly
11.Howis46(decimal)representedinan8-bit2'scomplementbinaryformat?
(a)
a.00101110
b.01000110
c.00011110
d.00101100
12.WhatisthevalueofthefollowingCexpression?
(d)
0x1234^0x5432(这是XOR运算)
a.0x1030
b.0x5434
c.0x5636
d.0x4606
MultipleChoiceQuiz3
1:
Theprogramcountercontains(D)
a.thenumberofCPUinstructionsaprogramhasexecutedsofar
b.thenumberoftimesaprogramhasbeenexecuted
c.theamountofmemoryaprogramiscurrentlyusing
d.theaddressoftheCPUinstructionthatisabouttobefetched
2:
Whichofthefollowingisagoodreason(aregoodreasons)toequiptheCPUwithsmallamountsoffastmemory?
(a)
I.Tomakethedesignofthecompilersimpler
II.TomakesomeCPUinstructionssmaller
III.TomakesomeCPUinstructionsfaster
a.IIandIIIonly
b.I,II,andIII
c.IIIonly
d.IIonly
3.WhichofthefollowingmustbetrueifaprogramisstoppedataspecificlinewithintheVisualC++debugger?
(D)
I.Thereisatleastonebreakpointenabled.
II.Thereisabreakpointenabledonthatline.
III.Thereisabreakpointenabledonthelineprecedingthatline.
a.Ionly
b.IandIIonly
c.IandIIIonly
d.none
4:
ProgramscompiledforanIntelPentiumprocessordonotexecuteproperlyon
aSPARCprocessorfromSunMicrosystemsbecause(B)
a.copyrightsregardingcodecannotbeviolated
b.theoperationcodesunderstoodbythetwoprocessorsaredifferent
c.theassemblymnemonicsforthesame"opcode"aredifferentinthetwoprocessors
d.thememoryofaSPARCCPUisnumberedfromtoptobottom
5:
WithinVisualC++,whichofthefollowingwillrevealthevalueofvariablewhentheprogramisstoppedatabreakpoint?
(B)
I.Placingthemousepointeroverthevariablenameinthesourcefilewindow.
II.Insertingaprintf()intheprogram.
III.Typingthevariablenameonthe"Watch"window.
a.IIIonly
b.IandIIIonly
c.I,II,andIII
d.IIandIIIonly
6:
ImmediatelyaftertheCPUexecutesaninstructionthatisneitherabranch
norajumpinstruction,theprogramcounter(B)
a.remainsunchanged
b.isincrementedtopointtothefollowinginstruction
c.hasavaluethatcannotbedeterminedwithoutfurtherinformation
d.isincrementedbyone
7:
ACPUregisterisawordofCPUmemorythat(C)
a.housesacriticalvariableforthedurationoftheexecutionofaprogram
b.recordstheresultsofperiodicCPUdiagnostics
c.isexplicitlyloadedandunloadedfromnormalmemorybycompiler-generatedinstructions
d.isautomaticallyloadedwhenaCPUinstructionreferstoawordofnormalmemory
8:
WhichofthefollowingcomputationsmaybeperformedbyexactlyoneCPUinstruction?
(A)
1.a=5;
2.a=b+c*5;
3.for(i=0;i<10;i+=a[i++]);
a.Ionly
b.IIonly
c.I,II,andIII
d.IandIIonly
9:
Supposethat,usingatoolsuchasthememorywindowofVisualC++,wefoundthatacertainsetofcontiguousmemorylocationscontainedtheinteger0xC605CD623A8365000000.Whatcouldthesememorylocationshold?
(D)
1.theinteger0xC605CD623A8365000000
2.astring
3.aCPUinstruction
a.Ionly
b.IIIonly
c.IandIIonly
d.I,II,andIII
10:
Abranchinstruction(A)
a.setstheprogramcountertooneoftwopossiblevalues
b.increasestheprogramcounterbyafixedamount
c.setstheprogramcountertooneofmanypossiblevalues
d.unconditionallysetstheprogramcountertoitsoperand
11:
Ajumpinstruction(D)
a.changestheprogramcounteronlyifitsoperandisequaltozero
b.changesapointertopointtothenextelementofanarray
c.increasestheprogramcounter
d.unconditionallysetstheprogramcountertoitsoperand
12:
Themachinecodegeneratedfromsourcecodebyacompiler(C)
a.associatesvariablevalueswiththeirnames
b.executesmorequicklythanthesourcecode
c.doesnotpreservealltheinformationgiveninthesourcecode
d.canbeeasilyinspectedtocheckthecorrectnessofthecompiler
13:
Whichofthefollowingaretrueoftheeffectthatoptimizationshaveonthemachinecodegeneratedbycompilers?
(B)
I.Theresultingcodewillbefasterand/orsmaller.
II.Theresultingcodewillbeclearer.
III.Theresultingcodewillbehardertodebug.
a.I,II,andIII
b.IandIIIonly
c.IandIIonly
d.Ionly
MultipleChoiceQuiz4
1:
InC,assumingthataninttakes4bytes,ifarrayaisdeclar