Sie sind auf Seite 1von 8

11.

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)

11.2 The Data Hierarchy


11.3Ultimately,alldataitemsprocessedbyacomputerarereducedto________whicharethesmallest
dataitemsin
acomputer.
(a)characters
(b)bits
(c)bytes
(d)characters
ANS:(b)
11.4A________iscomposedof8bits
(a)byte
(b)field
(c)characterset
(d)both(a)and(c)
ANS:(a)
11.5Asequentialfileisorganizedbythe________field.
(a)record
(b)sequential
(c)key
(d)recordkey
ANS:(d)
11.6.Whichstatementistrue?
a)Thesmallestdataiteminacomputeriscalledabyte.
b)Digits,lettersandspecialsymbolsarereferredtoasmemorywords.
c)Fieldsarecomposedofrecords.
d)Bytesarecomposedofbits.
ANS:(d)
11.7.Tofacilitatetheretrievalofspecificrecordsfromafile,atleastonefieldineachrecordistypically
chosenasarecord_________.
a)index
b)key

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)

11.3 Files and Streams


11.11WhichofthefollowingisnotastreamassociatedwithCfiles?
(a)stdin
(b)stdout
(c)stdchar
(d)stderr
ANS:(c)
11.12WhichofthefollowingisnotpartoftheFILE structurespecifiedin<stdio.h>?
(a)filedescriptor
(b)openfiletable
(c)read/writemethods
(d)filecontrolblock
ANS:(c)
11.13.Cviewseachfilesimplyasasequentialstreamof__________.
a)bits
b)bytes
c)fields
d)records
ANS:(b)
11.14.WhichofthefollowingisnotautomaticallyopenedwhenaCprogrambegins?
a)standarderror
b)standardoutput

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)

11.4 Creating a Sequential-Access File


11.19Whichmodewouldyouuseifyouwantedtoopenafileforbothreadingandwriting?
(a)r+
(b)w+
(c)a+
(d)allofthese
ANS:(d)
11.20Ifanerroroccurswhileopeningafileinanymode,functionfopen returns________.
(a)true
(b)NULL
(c)false
(d)-1
ANS:(b)
11.21.Whichstatementistrue?
a)Cimposesnostructureonafile.
b)Cimposesrecordstructureonafile.
c)Cimposessequentialaccessonafile.
d)Cimposeshierarchicalaccessonafile.

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)

11.5 Reading Data from a Sequential-Access File


11.31Functionfscanf takesanargumentoftype________.
(a)FILE pointer
(b)cfPtr
(c)char
(d)int
ANS:(a)
11.32Whichofthefollowingisafunctionwhichcausesaprogramsfilepositionpointertobe
repositionedtothe
beginningofthefile?
(a)rescan
(b)rewind
(c)return
(d)noneofthese
ANS:(b)
11.33.Functionfscanfisequivalenttofunctionscanf,exceptthatfscanf
a)canhaveonlyasingleargument.
b)canreadonlyfromstandardstreams.
c)canreadonlyfromopenstreams.
d)receivesasanargumentafilepointerforthefilefromwhichthedataisread.
ANS:(d)
11.34.Therewindstatementcauses__________.
a)thedisktostopspinning,thenspininreverseuntilitrepositionstothebeginningofthefile
b)thecontentsofthefiletobeerased
c)aprogramsfilepositionpointertoberepositionedtothebeginningofthefile(i.e.,byte0)

d)workswithtapefilesbutnotdiskfiles
ANS:(c)
11.35.Whichstatementistrue?
a)ThefilepositionpointerisapointertoaFILEstructure.
b)ThefilepositionpointerisapointertoanFCB.
c)Thefilepositionpointerisnotreallyapointer.
d)Thefilepositionpointerspecifiesthefilereset.
ANS:(c)

11.6 Random-Access Files


11.36Individualrecordsofarandomlyaccessedfilearenormally________.
(a)fixedinlength
(b)notfixedinlength
(c)sortedbyrecordkey
(d)readusingthefopen function
ANS:(a)
11.37Whichofthefollowingisfalse?
(a)Datacanbeinsertedinarandomlyaccessedfilewithoutdestroyingotherdatainthefile
(b)Thereismorethanonewaytoimplementrandomlyaccessedfiles.
(c)Randomlyaccessedfilescannotbeaccesseddirectlywithoutsearchingthroughotherrecords.
(d)Datastoredpreviouslycanbeupdatedordeletedwithoutrewritingtheentirefile.
ANS:(c)
11.38.Whichstatementisfalse?
a)Randomlyaccessedfilesarepoularintransactionprocessingsystems.
b)Datastoredpreviouslyinarandomlyaccessedfilecanbeupdatedordeletedwithoutrewritingtheentire
file.
c)Recordsofarandomlyaccessedfilearenormallyfixedinlength(i.e.,alltherecordinthefilearethe
samelength).
d)Arecordofarandomlyaccessedfileisnormallylocatedbysearchingtheportionofthatfilewhich
precedesthatrecord.
ANS:(d)

11.7 Creating a Randomly Accessed File


11.39Whichofthefollowingisthefunctionusedtocreatearandomlyaccessedfile?
(a)fscanf
(b)fopen
(c)fwrite
(d)fread
ANS:(c)
11.40Whatisthesignificanceofthe1 inthefollowingstatement?
fwrite( &number, sizeof( int ), 1, fPtr );

(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)

11.8 Writing Data Randomly to a Randomly Accessed File


11.45Whichofthefollowingisanargumentofthefseek functionthatcanhavethevaluesSEEK_SET,
SEEK_CUR orSEEK_END?
(a)stream
(b)offset
(c)whence
(d)noneofthese
ANS:(c)
11.46.Whichstatementistrue?
a)fseeksearchesforarecordbyitsrecordkey.
b)fseeksetsthefilepositionpointertoaspecificbytelocationinthefile.
c)fseekmovesthereadwriteheadonthedisktothelocationondiskthatcorrespondstoaspecific
locationinafile.
d)fseekmustimmediatelyfolloweachcalltofreadorfwrite.
ANS:(b)
11.47.Thesymbolicconstant__________indicatesthatthefilepositionpointeristobepositionedrelative
tothebeginningofthefilebytheamountoftheoffset.
a)SEEK_SET

b)SEEK_BEGIN
c)SEEK_START
d)SEEK_CUR
ANS:(a)

11.9 Reading Data Randomly from a Randomly Accessed File


11.48Whichofthefollowingisafunctionthatreadsaspecifiednumberofbytesfromafileintomemory?
(a)fseek
(b)fwrite
(c)fread
(d)fopen
ANS:(c)
11.49.Whichstatementistrue?
a)freadalwaysreadsarecordatatimefromafileintomemory.
b)freadreadsaspecifiednumberofbytesfromafileintomemory.
c)Everyfreadcallmustincludeanargumentwithsizeof.
d)freadreadsbytesfromapositioninthefilespecifiedasoneoffreadsarguments.
ANS:(b)

11.10 Case Study: A Transaction-Processing Program


11.50.Inthestatement
fseek ( fPtr,
( account 1) * sizeof( struct clientData ),
( SEEK_SET );

takenfromthetransactionprocessingcasestudyyoustudiedinSection10.10,whyarewemakingthe
adjustmentby1?
a)Becausetheaccountnumbersstartat0andthefilestartsatposition0.
b)Becausetheaccountnumbersstartat0andthefilestartsatposition1.
c)Becausetheaccountnumbersstartat1andthefilestartsatposition0.
d)Becausetheaccountnumbersstartat1andthefilestartsatposition1.
ANS:(c)

Das könnte Ihnen auch gefallen