You are on page 1of 5

Take home pre-test Chapter 7 Deitel and Deitel

7.2 Pointer Variable Definitions and Initialization


7.1Pointerscannotbeusedto
(a)findtheaddressofavariableinmemory.
(b)referencevaluesdirectly.
(c)simulatecallbyreference.
(d)manipulatedynamicdatastructures.
7.2Pointersmaybeassignedwhichofthefollowing?
(a)allintegervalues
(b)anaddress
(c)NULL
(d)both(b)and(c)
7.4 A nonpointer variable name __________ references a value and a pointer variable name __________
referencesavalue.
a)directly,directly
b)directly,indirectly
c)indirectly,directly
d)indirectly,indirectly
7.6Referencingavaluethroughapointeriscalled__________.
a)interdiction
b)indirection
c)intermediation
d)redirection
7.8Whichstatementaboutpointersisfalse?
a)ApointerwiththevalueNULLpointstonothing.
b)NULLisasymbolicconstantdefinedinthe<stdio.h>headerfile.
c)Initializingapointerto0isequivalenttoinitializingapointertoNULL,butNULLispreferred.
d)Thevalues0and1aretheonlyvaluesthatcanbeassigneddirectlytoapointervariable.

7.3 Pointer Operators


7.9The&operatorcanbeappliedto
(a)constants
(b)variablesdefinedwiththestorageclassregister
(c)variablesdefinedwiththestorageclassstatic
(d)rvalues
7.10Threeofthefollowingexpressionshavethesamevalue.Whichofthefollowingsvalueisdifferentfromthe
others?
(a)*&Ptr
(b)&*Ptr
(c)*Ptr
(d)Ptr
7.12Thestatement
y = &yPtr;

a)assignstheaddressofthevariableytopointervariableyPtr.

Take home pre-test Chapter 7 Deitel and Deitel


b)assignstheaddressofthevariableyPtrtopointervariabley.
c)isacompilationerror.
d)isalogicerror.
7.14Whichstatementisfalse?
a)Theunary*operatoriscalledtheindirectionoperatororthedereferencingoperator.
b)Theoperandoftheunary*operatormustbeapointer.
c)Theunary*operatorreturnsthevalueofitsoperand.
d)Placinga*operatorbeforeapointerdereferencesthepointer.
7.16Theunary*and__________arecomplementsofoneanother.
a)/
b)^
c)&
d)|

7.4 Passing Arguments to Functions by Reference


7.18Whichstatementisfalse?
a)AllfunctioncallsinCpassargumentscallbyvalue.
b)Callbyreferenceenablesacalledfunctiontomodifyvariablesinthecallingfunction.
c)Callbyvalueisalwaysmoreefficientthancallbyreference.
d)InC,programmersusepointersandtheindirectionoperatortosimulatecallbyreference.
7.20IfarraynamearrayNameispassedtoafunction,Cautomaticallypasses__________.
a)&arrayName[ 0 ]
b)arrayName[ 1 ]
c)arrayName[ 0 ]
d)*arrayName
7.22Whichstatementisfalse?
a)Itsnecessarytoincludenamesofpointerargumentsinfunctionprototypes.
b)Afunctionreceivinganaddressasanargumentmustdefineapointerparametertoreceivetheaddress.
c)Thecompilerdoesnotdistinguishbetweenafunctionthatreceivesapointerandafunctionthatreceivesasingle
subscriptedarray.
d)Thefunctionmustknowwhetheritisreceivingasinglesubscriptedarrayorsimplyasinglevariableforwhich
itistoperformsimulatedcallbyreference.

7.5 Using the const Qualifier with Pointers


7.24Afunctionthatprintsastringshouldhaveaparameterthatsa
(a)nonconstantpointertononconstantdata.
(b)nonconstantpointertoconstantdata.
(c)constantpointertononconstantdata.
(d)constantpointertoconstantdata.
7.26.Whichstatementisfalse?
a)Theconstqualifierenablestheprogrammertoinformthecompilerthatthevalueofaparticularvariableshould
notbemodified.
b)TheconstqualifierdidnotexistinearlyversionsofC;itwasaddedtothelanguagebytheANSICcommittee.
c)Usingtheconstqualifiertypicallyviolatestheprincipleofleastprivilege
d)AddingconsttoCprogramsthatdonotuseitpresentssignificantopportunitiesforimprovementinthesoftware
engineeringofthatcode.

Take home pre-test Chapter 7 Deitel and Deitel


7.28Whichstatementisfalse?
a)Ifavalueshouldnotchangeinthebodyofafunctiontowhichitispassed,thevalueshouldbedefined constto
ensurethatitisnotaccidentallymodified.
b)Attemptstomodifythevalueofavariabledefinedconstarecaughtatexecutiontime.
c)Onewaytopassapointertoafunctionistouseanonconstantpointertononconstantdata.
d)Itisdangeroustopassanonpointerintoapointerargument.
7.30Whichstatementisfalse?
a)Arraysandstructuresareaggregatedatatypes.
b)StructuresinCaresometimescalledrecordsinotherlanguages.
c)Astructureiscapableofstoringmanyrelateddataitemsofdifferentdatatypes.
d)Structuresarealwayspassedcallbyreference.
7.32Theleastaccessprivilegeisgrantedbya__________pointerto__________data.
a)nonconstant,nonconstant
b)nonconstant,constant
c)constant,nonconstant
d)constant,constant

7.6 Bubble Sort Using Pass-by-Reference


7.33Whichstatementisfalse?
a)Thenotationsint *arrayandint array[]areinterchangeable.
b)Functionprototypesmaynotbeplacedinsidefunctions.
c)Goodadvice:Toencouragesoftwarereusability,whenpassinganarray,alsopassthesizeofthearray.
d)Globalvariableviolatetheprincipleofleastprivilege.

7.7 sizeof Operator


7.34sizeof
(a)isabinaryoperator
(b)returnsthetotalnumberofelementsinanarray
(c)usuallyreturnsadouble
(d)returnsthetotalnumberofbytesinanarray
7.36Whichstatementisfalse?
a)Usingglobalvariables,insteadofpassingarguments,canincreaseprogramperformance,butreduceeffective
softwareengineering.
b)Hardcodingintoafunctionthesizeofanarraythatwillbepassedasanargumentratherthanpassingthesizeof
thearrayasaparameter,reducesthesoftwarereusabilityofthatfunction.
c)sizeofisanoperatorthatcalculatesthesizeofitsargumentinbytesatcompiletime.
d)Whenappliedtothenameofanarray,sizeofreturnsthenumberofelementsinthearray.

7.8 Pointer Expressions and Pointer Arithmetic


7.38Whichofthefollowingcanhaveapointerasanoperand?
(a)++
(b)*=
(c)%
(d)/
7.40Apointercannotbeassignedto

Take home pre-test Chapter 7 Deitel and Deitel


(a)anotherpointerofthesametype
(b)apointertovoid
(c)apointerofatypeotherthanitsowntypeandvoid
(d)anyotherpointerbyusingthecastoperator
7.42Whichstatementisfalse?
a)Apointermaybeincrementedordecremented.
b)Anintegermaybeaddedtoapointer.
c)Alloperatorsnormallyusedinarithmeticexpressions,assignmentexpressionsandcomparisonexpressionsare
validinconjunctionwithpointervariables.
d)Apointermaynotbeaddedtoapointer.

7.9 Relationship Between Pointers and Arrays


7.44AssumingthattisanarrayandtPtrisapointertothatarray,whatexpressionreferstotheaddressofelement
3?
(a)*( tPtr + 3 )
(b)tPtr[ 3 ]
(c)&t[ 3 ]
(d)*( t + 3 )
7.46IfbPtrisassignedb(thenameofanarray),thenarrayelement b[ 3 ]canalternativelybereferencedwiththe
pointerexpression__________.
a)bPtr + 3
b)b[ bPtr + 3 ]
c)*b [ bPtr + 3 ]
d)*( bPtr + 3)

7.10 Arrays of Pointers


7.48Whichstatementisfalse?
a)InC,astringisessentiallyapointertoitsfirstcharacter.
b)Arraysmaycontainpointers.
c)Eachentryinanarrayofstringsisactuallyapointertothefirstcharacterofastring.
d)Thesizeofanarrayofstringsisthesumofthelengthsofthestrings.

7.11 Case Study: Card Shuffling and Dealing Simulation


7.50WhichstatementaboutthealgorithmwepresentedinSection7.10ofthetextforshufflingadeckofcardsis
true?
a)Itsguaranteedtoterminate.
b)Itcouldexecuteindefinitely.
c)Itsefficient.
d)Itusesaonedimensionalarrayof52cards.

7.12 Pointers to Functions


7.52 ( *max )( num1, num2, num3 );
(a)istheheaderforfunctionmax
(b)isacalltofunctionmax
(c)istheprototypeforfunctionmax

Take home pre-test Chapter 7 Deitel and Deitel


(d)ispartofadefinitionofapointertothefunctionmax

7.13 Secure C Programming


7.56 Which of the following statements is false?
(a) Dereferencing NULL pointers typically causes programs to crash.
(b) If a function parameter points to a value that will not be changed by the function, const should be used to
indicate that the data is constant.
(c) Attackers cannot execute code by dereferencing a NULL pointer.
(d) None of the above.

You might also like