Documente Academic
Documente Profesional
Documente Cultură
1 Introduction
11.1________areusedforpermanentretentionoflargeamountsofdata.
(a)Structures
(b)Arrays
(c)Records
(d)Files
ANS:(d)
11.2.Whichofthefollowingisfalse?
a)Storageofdatainmemoryvariablesistemporary;allsuchdataislostwhenaprogramterminates.
b)Computersstorefilesonprimarystoragedevices,typicallydiskstoragedevices.
c)Filesareusedforpermanentretentionofdata(typicallylargeamountsofdata).
d)Storageofdatainmemoryarraysistemporary;allsuchdataislostwhenaprogramterminates.
ANS:(b)
c)name
d)location
ANS:(b)
11.8.Themostpopulartypeoffileorganizationisthe__________file.
a)sequential
b)database
c)hierarchy
d)collection
ANS:(a)
11.9.Thesetofcharactersthatmaybeusedtowriteprogramsandrepresentdataitemsonaparticular
computeriscalledthatcomputers_________set.
a)data
b)file
c)byte
d)character
ANS:(d)
11.10.Agroupofrelatedfilesiscalleda__________.
a)databasemanagementsystem
b)database
c)dataset
d)datahierarchy
ANS:(b)
c)standarddialog
d)standardinput
ANS:(c)
11.15.__________providecommunicationchannelsbetweenfilesandprograms.
a)Streams
b)Records
c)Filedescriptors
d)Filecontrolblocks(FCBs)
ANS:(a)
11.16.Thestandard__________streamenablesaprogramtoreaddatafromthekeyboard.
a)read
b)keyboard
c)dialog
d)input
ANS:(d)
11.17.Function__________readsonecharacterfromafile.
a)fgetcharacter
b)fgetc
c)fgetchar
d)fgetbyte
ANS:(b)
11.18.Functionfputswritesa__________toafile.
a)character
b)stream
c)line
d)standardoutput
ANS:(c)
ANS:(a)
11.22.Whichstatementisfalse?
a)Theprogrammermustprovideanyfilestructuretomeettherequirementsofeachparticularapplication.
b)Aprogrammercanimposearecordstructureonafile.
c)RecordsmustbewrittentoaCfileinorderbyrecordkey.
d)ThenotionofarecordofafiledoesnotexistinC.
ANS:(c)
11.23.Whichofthefollowingstatementsisfalse?
a)TheprogrammermustknowthespecificsoftheFILEstructuretousefiles.
b)TheFILEstructureforafileleadsindirectlytotheoperatingsystemsfilecontrolblock(FCB)forafile.
c)Ifafiledoesnotexistandisopenedforwritingfopencreatesthefile.
d)ACprogramadministerseachfilewithaseparateFILEstructure.
ANS:(a)
11.24.Beforeafilecanbeaccesseditmustfirstbe
a)copied
b)read
c)written
d)opened
ANS:(d)
11.25.Ifanexistingfileisopenedforwriting__________.
a)thecontentsofthefilearepreserved
b)thecontentsofthefilearediscardedandanerrorcodeisreturned
c)thecontentsofthefilearediscardedwithoutwarning
d)thenewlywrittendataisappendedtotheendofthefile
ANS:(c)
11.26.Functionfeof__________.
a)forcesanendoffilecondition
b)determineswhethertheendoffileindicatorissetforafile
c)setstheendoffileindicatorforafile
d)flushesthecontentsofthefilefromthecurrentpositiontotheend
ANS:(b)
11.26.Whichstatementistrue?
a)Functionfprintfisequivalenttoprintf.
b)Functionfprintfisequivalenttoprintfexceptthatfprintfalsoreceivesasanargumentafilepointerfor
thefiletowhichthedatawillbewritten.
c)Functionfprintfisequivalenttoprintfexceptthatfprintfalsoreceivesasanargumentafilecontrol
blockforthefiletowhichthedatawillbewritten.
d)Functionfprintfisequivalenttoprintfexceptthatfprintfalsodisablesthefileendoffileindicator.
ANS:(b)
11.27.Ifafileisnotclosedexplicitlybyaprogram__________.
a)theoperatingsystemnormallywillclosethefilewhenprogramexecutionterminates
b)thefilewillbeleftopenwhentheprogramterminates,creatingapossiblesecuritybreach
c)theoperatingsystemwillquerytheusertodetermineifheorshewishestoclosethefilewhenthe
programterminates
d)theoperatingsystemwillnotallowtheownerofthatprogramtorunanyotherprograms
ANS:(a)
11.28.Whichstatementisfalse?
a)Eachfileusedinaprogrammusthaveauniquenameandwillhaveadifferentfilepointerreturnedby
fopen.
b)Allsubsequentfileprocessingfunctionsafterthefileisopenedmustrefertothefilewiththeappropriate
filecontrolblock.
c)Tocreateafileusefileopenmodew.
d)Toaddrecordstoanexistingfile,penthefileforappending(a).
ANS:(b)
11.29.Ifanerroroccurswhileopeningafileinanymode,fopen__________.
a)causesprogramtermination
b)returnsNULL
c)issuesthemessagecant open file
d)diagnosestheerror,waitsfiveminutesandretries
Ans:(b)
11.30.Whichstatementistrue?
a)fopenreturnsaFILEstructure.
b)fopenreturnsapointertoaFILEstructure.
c)fopenreturnsafilecontrolblock(FCB).
d)fopenreturnsapointertoafilecontrolblock(FCB).
ANS:(b)
d)workswithtapefilesbutnotdiskfiles
ANS:(c)
11.35.Whichstatementistrue?
a)ThefilepositionpointerisapointertoaFILEstructure.
b)ThefilepositionpointerisapointertoanFCB.
c)Thefilepositionpointerisnotreallyapointer.
d)Thefilepositionpointerspecifiesthefilereset.
ANS:(c)
(a)Itspecifiesthatthefileistobeopenedforupdating.
(b)Itspecifiesthenumberofelementsinthearraythatshouldwrittentodisk.
(c)Itspecifiesthebytesizeoftheelementbeingwrittentodisk
(d)noneofthese
ANS:(b)
11.41.Functionfwrite__________.
a)isequivalenttofunctionfprintf
b)transfersaspecifiednumberofbytesbeginningataspecifiedlocationinmemorytoalocationinafile
indicatedbythefilepositionpointer
c)transfersaspecifiednumberofbytesbeginningataspecifiedlocationinmemorytoalocationinafile
indicatedbyoneofitsarguments
d)isequivalenttofunctionfprintf,exceptthatfwritecanonlywritetostandardstreams
ANS:(b)
11.42.freadandfwrite
a)cannotreadandwritearraysofdata
b)processalltheirdatainhumanreadableformat
c)processalltheirdatainthesameformatusedbyfscanfandfprintf,respectively
d)processalltheirdatainrawformat
ANS:(d)
11.43.Whichstatementistrue?
a)Randomaccessfileprocessingprogramstypicallyreadandwriteonefieldatatime.
b)Randomaccessfileprocessingprogramstypicallyreadandwriteonestructatatime.
c)Thesizeofoperatorisaruntimeunaryoperatorthatreturnsthesizeinbytesofitsoperand.
d)Theexpressionsizeof( int )alwaysreturns4.
ANS:(b)
11.44.sizeof
a)isacompiletimefunction
b)isacompiletimeunaryoperator
c)isaruntimeunaryoperator
d)isaruntimefunction
ANS:(b)
b)SEEK_BEGIN
c)SEEK_START
d)SEEK_CUR
ANS:(a)
takenfromthetransactionprocessingcasestudyyoustudiedinSection10.10,whyarewemakingthe
adjustmentby1?
a)Becausetheaccountnumbersstartat0andthefilestartsatposition0.
b)Becausetheaccountnumbersstartat0andthefilestartsatposition1.
c)Becausetheaccountnumbersstartat1andthefilestartsatposition0.
d)Becausetheaccountnumbersstartat1andthefilestartsatposition1.
ANS:(c)