Académique Documents
Professionnel Documents
Culture Documents
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)
(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)
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)
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)
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.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)
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)
a)Usingbitfieldscanbeaneffectivespacesavingtechnique.
b)Usingbitfieldsalwaysresultsinfasterexecutingmachinelanguage.
c)Thedecisiontousebitfieldsisoneofmanyexamplesofthekindsofspacetime
tradeoffsthatoccurincomputerscience.
d)Anunnamedbitfieldwithanonzerowidthisusedaspaddinginastructofbitfields.
ANS:(b)