Вы находитесь на странице: 1из 11

10.

1 Introduction
10.1________maycontaindifferentdatatypes.
(a)structures
(b)arrays
(c)bothaandb
(d)noneofthese
ANS:(a)
10.2.__________arecollectionsofrelatedvariablessometimesreferredtoas
aggregatesunderonename.
a)Members
b)Enumerations
c)Structures
d)Files
ANS:(c)
10.3.Structuresmaycontainvariablesofmanydifferentdatatypesincontrastto
___________thatcontainonlyelementsofthesamedatatype.
a)files
b)arrays
c)constants
d)functions
ANS:(b)

10.2 Structure Definitions


10.4Twostructurevariableswiththesamemembervalues
(a)alwayscompareequally.
(b)nevercompareequally.
(c)sometimescompareequally.
(d)onlycompareequallyifbothstructurevariablescontainholes.
ANS:(c)
10.5Whatdoesthedeck[52]arraycontaininthefollowingstatement?
struct card a, deck[52], *cPtr;
(a)cardstructureelements
(b)astructureelements
(c)*cPtrelements

(d)noneofthese
ANS:(a)
10.6.Keyword__________introducesthestructuredefinition.

a)structure
b)str
c)strdef
d)struct
ANS:(d)
10.7.Astructurecontainingamemberthatisapointertothesamestructuretypeis
referredtoasa__________structure.
a)selfreferential
b)selfdescribing
c)selfaggrandizing
d)selfelemental
ANS:(a)
10.8.Whichstatementisfalse?
a)Structuresarederiveddatatypes.
b)Eachstructuredefinitionmustendwithasemicolon.
c)Astructurecancontainaninstanceofitself.
d)Structuresmaynotbecomparedusingoperators==and!=.
ANS:(c)
10.9.Whichofthefollowingisnotavalidoperationonastructure?
a)Assigningstructurevariablestostructurevariablesofthesametype.
b)Takingtheaddressofastructurevariable.
c)Usingthesizeofoperatortodeterminethesizeofastructurevariable.
d)Comparingstructuresofthesametypewithrelationaloperators.
ANS:(d)

10.3 Initializing Structures


10.10Structurevariablesmaynotbeinitializedby
(a)settinguserdefineddefaultsinthestructdefinition.
(b)assigningvaluestoindividualdatamembers.
(c)arraylikememberinitializerlists.
(d)assignmentstatements.
ANS:(a)
10.11Whatdoesthefollowingstatementdo?

struct card a = { Three, Hearts };


(a)Itcreatesavariablecardoftypestructwithtwomembersspecifiedinthelist.
(b)ItcreatestwovariablesnamedThreeandHeartsoftypestructcarda.
(c)Itcreatesavariableatobeoftypestructcardandinitializesittothevaluesinthe

list.
(d)ItcreatestwovariablesnamedThreeandHeartsoftypestructcard.

ANS:(c)
10.12.Iftherearefewer__________inthelistthanmembersinthestructure,the
remainingmembersareautomaticallyinitializedto0orNULL.
a)quantifiers
b)initializers
c)numerators
d)variables
ANS:(b)
10.13.Structurescanbeinitializedin__________statements.
a)assignment
b)null
c)scope
d)empty
ANS:(a)

10.4 Accessing Members of Structures


10.14Arraysare
(a)alwayspassedcallbyreference.
(b)passedcallbyreferenceunlessinsideastructure.
(c)alwayspassedcallbyvalue.
(d)passedcallbyvalueunlessinsideastructure.
ANS:(b)
10.15The________accessesastructurememberviathestructurevariablename.
(a)structurememberoperator
(b)structurepointeroperator
(c)structurearrowoperator
(d)noneofthese
ANS:(a)
10.16.Thestructurememberoperatoraccessesastructurememberviathestructure
variablename.
a)apointertothemember
b)thescoperesolutionoperator
c)anoverloadedoperator
d)thestructurevariablename
ANS:(d)
10.17.Theexpressionaptr->suitisequivalentto__________.
a)aptr.suit
b)*aptr.suit

c)(*aptr).suit
d)*aptr.(suit)
ANS:(c)
10.18.Whichofthefollowingisfalse
a)Structuremembernamesthroughoutaprogrammustbeunique.
b)Attemptingtorefertoamemberofastructurebyusingonlythemembersnameisan
error.
c)Insertingaspacebetweenthe-and>ofoperator->isanerror.
d)Thedotoperator(.)isthestructurememberoperator.
ANS:(a)

10.5 Using Structures with Functions


10.19Structuresmaybepassedtofunctionsby________.
(a)passingindividualstructuremembers
(b)passinganentirestructure
(c)passingapointertothestructure
(d)allofthese
ANS:(d)
10.20Arraysofstructures________.
(a)areautomaticallypassedcallbyreference
(b)areautomaticallypassedcallbyvalue
(c)cannotbepassedcallbyreference
(d)cannotbepassedcallbyvalue
ANS:(a)
10.21.Astructureofarraysisautomaticallypassed__________.
a)callbyvalue
b)callbyreference
c)callbyaggregate
d)callbymasking
ANS:(a)
10.22.Anarrayofstructuresisautomaticallypassed__________.
a)callbyvalue
b)callbyreference
c)callbyaggregate
d)callbyenumeration
ANS:(b)
10.23.Whichofthefollowingisfalse?
a)Topassastructurecallbyreference,passtheaddressofthestructurevariable.

b)Awaytopassanarraycallbyvalue,istocreateastructurewiththearrayasamember
thenpassthenameofthestructure.
c)Topassastructurecallbyreference,passthenameofthestructurevariable.
d)Passinglargestructurescallbyreferenceismoreefficientthanpassinglargestructures
callbyvalue.
ANS:(c)

10.6 typedef
10.24typedefisusedto
(a)createanamethatisanaliasforanothername.
(b)createnewdatatypes.
(c)castonestructtoanothertype.
(d)initializestructmembers.
ANS:(a)
10.25Anadvantageoftypedefdoesnotinclude
(a)makingprogramsmoreportablebyallowingdatatypestobeeasilychangedtomeet
systemspecifications.
(b)makingtypenamesshorter.
(c)makingprogramsmorereadable.
(d)increasingtheefficiencyofaccessingstructmembervariables.
ANS:(d)
10.26.Creatinganewnamewithtypedef__________.
a)createsanewtype
b)createsanewtypename
c)createsanewvariablename
d)createsanewvariable
ANS:(b)
10.27.Whichstatementistrue?
a)Often,typedefisusedtocreatesynonymsforthebasicdatatypes.
b)Keywordtypedefisusedtocreateantonyms(oropposites)forthebasicdatatypes.
c)Namesforstructuretypesaretypicallydefinedwithtypedeftocreatelongertype
names.
d)Thefirstletterofeachtypedefnamemustbecapitalized.
ANS:(a)

10.7 Example: High-Performance Card-shuffling and Dealing


Simulation

10.28WhichistheproperwaytocreateanarrayofstructuresoftypeData?
(a)MyArray Data[10];
(b)Data MyArray[10];
(c)Data struct MyArray[10];
(d)struct MyArray[Data];
ANS:(b)
10.29.Whatdoesthestatementtypedef struct card Card;do?
a)DefinescardasasynonymforCard.
b)DefinesCardasasynonymforcard.
c)DefinesCardasasynonymforstruct card.
d)DefinesCardasasynonymfortypedef struct card.
ANS:(c)
10.30.Whichofthefollowingisaalwaysasyntaxerror?
a)Notusingsrandineveryprogramthatusesrand.
b)Notusingrandineveryprogramthatusessrand.
c)Notusingconstwhenpassinganarray.
d)Forgettingtoincludethearraysubscriptwhenreferringtoindividualstructuresinan
arrayofstructures.
ANS:(d)

10.8 Unions
10.31Whichofthefollowingistrue?
(a)Unionsmaybecomparedusingthe==operator.
(b)Theaddressoperator(&)cannotbeusedtotaketheaddressofaunion.
(c)Unionsmayonlycontaintwodatatypes.
(d)Onlyoneunionmember,andthusonedatatype,canbereferencedatatime
ANS:(d)
10.32Whichofthefollowingisnotanoperationthatcanbeperformedonaunion?
(a)comparingusingthe!=operator
(b)takingtheaddress(&)ofaunion
(c)accessingunionmembersusingthestructurememberoperator
(d)assigningauniontoanotherunionofthesametype
ANS:(a)
10.33.Whichofthefollowingistrue?
a)Auniontypicallymakeslessefficientuseofmemorythanastruct.
b)Aunionisanothernameforastruct.
c)Aunionisaderiveddatatypewhosememberssharethesamestoragespace.
d)Unionsarealwaysportablebetweendifferentcomputerswithdifferentcompilers.
ANS:(c)

10.34.Whichstatementistrue?
a)Themembersofaunioncanbeofanytype.
b)Themembersofaunionmustallbeofthesametype.
c)Aunionmaynotbeassignedtoanotherunionofthesametype.
d)Unionsmaybecomparedtootherunionsofthesametype.
ANS:(a)

10.9 Bitwise Operators


10.35Themostbasicunitofdataonacomputeristhe
(a)bit.
(b)byte.
(c)file.
(d)int.
ANS:(a)
10.36Whichofthefollowingisnotabitwiseoperator?
(a)^
(b)&
(c)~
(d)*
ANS:(d)
10.37LetBit1 = Bit2 = 1.Whichofthefollowingdoesnothavethesameresultasthe
others?
(a)Bit1 & Bit2
(b)Bit1 | Bit2
(c)Bit1^Bit2
(d)~(~Bit2)
ANS:(c)

10.38Evaluate(00001000 & 11000101) ^ (11110000)


(a)00111101
(b)11000000
(c)00111101
(d)11110000
ANS:(d)
10.39Letxbeanintonamachinewith4byteints.Whateffectdoes
x<<=1;

x>>=1;

have?
(a)Thereisnoeffect.
(b)Theleftmostbitofxissettozero.
(c)Therightmostbitofxissettozero.
(d)Both(b)and(c).
ANS:(b)
10.40Forany8bitx,whichofthefollowingdoesnotresultinzero?
(a)x &= (~x)
(b)x ^= x
(c)x <<= 8
(d)x |= x
ANS:(d)
10.41.Thebitwiseoperatorscanbeusedtomanipulatethebitsofvariablesoftype
__________.
a)float
b)double
c)long
d)long double
ANS:(c)
10.42.Whichoperatorsetsthebitsintheresultto1onlywhenthecorrespondingbitsin
thetwooperandsareboth1?
a)bitwiseAND
b)bitwiseinclusiveOR
c)bitwiseexclusiveOR
d)bitwisecomplement
ANS:(a)
10.43.Whichoperatorsetsthebitsintheresultto1ifatleastoneofthecorresponding
bitsinthetwooperandsis1?
a)bitwiseAND
b)bitwiseinclusiveOR
c)bitwiseexclusiveOR
d)bitwisecomplement
ANS:(b)
10.44.Whichoperatorsetsthebitsintheresultto1ifatexactlyoneofthecorresponding
bitsinthetwooperandsis1?
a)bitwiseAND
b)bitwiseinclusiveOR
c)bitwiseexclusiveOR

d)bitwisecomplement
ANS:(c)
10.45.Whichstatementistrueofthe<<operator?
a)Itiscalledtherightshiftoperator.
b)Itiscalledthebitwiserightshiftoperator.
c)Itshiftsthebitsofthesecondoperandleftbythenumberofbitsspecifiedbythefirst
operand.
d)Itfillsfromtherightwith0bits.
ANS:(d)
10.46.Whichstatementistrueofthe>>operator?
a)Itiscalledtheleftshiftoperator.
b)Itiscalledthebitwiseleftshiftoperator.
c)Itshiftsthebitsofthefirstoperandrightbythenumberofbitsspecifiedbythesecond
operand.
d)Itfillsfromtheleftportablyacrossplatforms.
ANS:(c)
10.47.Inbitwisemanipulations,amaskistypically__________.
a)Afloatingpointvaluewithspecificbitssetto1.
b)Anintegervaluewithspecificbitssetto1.
c)Anintegervaluewithspecificbitssetto0.
d)Afloatingpointvaluewithspecificbitssetto0.
ANS:(b)
10.48.Whichofthefollowingistrue?
a)AnybitANDedwith0yields0.
b)AnybitANDedwith1yields1.
c)AnybitANDedwith0yields1.
d)AnybitANDedwith1yields0.
ANS:(a)
10.49.Whichstatementistrue?
a)||isthebitwiseoroperator,
b)|isthelogicaloroperator
c)Operators||areinterchangeable.
d)||and|areeachbinaryoperators.
ANS:(d)
10.50.Whichstatementisfalse?
a)Theresultofshiftingavalueisundefinediftherightoperandisnegative.
b)Theresultofshiftingavalueisundefinediftherightoperandhasmorebitsthanthe
numberofbitsinwhichtheleftoperandisstored.

c)Leftshiftingismachinedependent.
d)Rightshiftingismachinedependent.
ANS:(c)

10.10 Bit Fields


10.51Abitfieldmustbedefinedasa__________.
(a)intorunsigned
(b)char
(c)float
(d)long
ANS:(a)
10.52Thenumberofbitsinabitfieldisspecifiedwith__________.
(a)parenthesisasinbitfield(4)
(b)acolonasinbitfield : 4
(c)bracketsasinbitfield[4]
(d)adotasinbitfield.4
ANS:(b)
10.53__________isnotallowed.
(a)Accessingindividualbitsinamultibitbitfield.
(b)Paddingabitfieldwithbitsthatcannotbeaccessed
(c)Havinganunnamedbitfield.
(d)Havingabitfieldwithazerowidth.
ANS:(a)
10.54.Whichstatementisfalse?
a)Bitfieldmanipulationsaremachinedependent.
b)Bitfieldsmaynevercrossawordboundary.
c)Bitfieldsarenotarraysofbits.
d)Itisnotpossibletotaketheaddressofabitfield.
ANS:(b)
10.55.Anunnamedbitfieldwithazerowidthisusedto__________.
a)purgeabitfromabitfield
b)initializeabitfieldto0.
c)concatenatetwobitfields.
d)alignthenextbitfieldonanewstorageunitboundary.
ANS:(d)
10.56.Whichstatementisfalse?

a)Usingbitfieldscanbeaneffectivespacesavingtechnique.
b)Usingbitfieldsalwaysresultsinfasterexecutingmachinelanguage.
c)Thedecisiontousebitfieldsisoneofmanyexamplesofthekindsofspacetime
tradeoffsthatoccurincomputerscience.
d)Anunnamedbitfieldwithanonzerowidthisusedaspaddinginastructofbitfields.
ANS:(b)

10.11 Enumeration Constants


10.57Enumerationconstants
(a)musthaveuniqueintegervalues
(b)canbeassignedothervaluesoncetheyhavebeendefined
(c)musthaveuniqueidentifiers
(d)aredefinedusingthekeywordconst
ANS:(c)
10.58.Whichofthefollowingisasyntaxerror?
a)Assigningavaluetoanenumerationconstantwhencreatinganenumerationtype.
b)Anenumerationisasetofintegerconstantsrepresentedbyidentifiers.
c)Enumerationconstantvaluescanbesetautomatically.
d)Assigningavaluetoanenumerationconstantafterithasbeendefined.
ANS:(d)
10.59.Whichstatementistrue?
a)Theidentifiersinanenumerationmustbeunique.
b)Theconstantvaluesassignedtomembersofanenumerationmustbeunique.
c)Enumerationconstantnamesmustconsistofalluppercaseletters.
d)enum months monthdefinesvariablemonthstobeoftypemonth.
ANS:(a)

Вам также может понравиться