100% found this document useful (29 votes)
561 views

C++ For Engineers and Scientists 4th Edition Bronson Test Bank Download

This document contains sample questions and answers from a test bank for Chapter 8: I/O Streams and Data Files from the textbook "C++ for Engineers and Scientists 4th Edition" by Bronson. The chapter questions cover topics about files, file streams, opening and closing files, reading from and writing to files, and file access methods.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (29 votes)
561 views

C++ For Engineers and Scientists 4th Edition Bronson Test Bank Download

This document contains sample questions and answers from a test bank for Chapter 8: I/O Streams and Data Files from the textbook "C++ for Engineers and Scientists 4th Edition" by Bronson. The chapter questions cover topics about files, file streams, opening and closing files, reading from and writing to files, and file access methods.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

C++ FOR ENGINEERS AND SCIEN-

TISTS 4TH EDITION BRONSON

Full download at link:

Test bank: https://testbankpack.com/p/test-bank-for-c-for-engineers-


and-scientists-4th-edition-by-bronson-isbn-1133187846-
9781133187844/

Solution Manual: https://testbankpack.com/p/solution-manual-for-c-


for-engineers-and-scientists-4th-edition-by-bronson-isbn-
1133187846-9781133187844/

Chapter 8: I/O Streams and Data Files

TRUE/FALSE

1. A file is a collection of data stored together under a common name, usually on a disk.

ANS: T PTS: 1 REF: 462

2. All computer operating systems use the same specification as to the maximum number of characters
permitted for an external filename.

ANS: F PTS: 1 REF: 462

3. Current versions of UNIX allow 14 characters as the maximum filename length.

ANS: F PTS: 1 REF: 462

4. Long filenames should be avoided because they take more time to type and can result in typing errors.

ANS: T PTS: 1 REF: 462

5. Opening a file connects a file stream object to a specific external filename.

ANS: T PTS: 1 REF: 464

6. You must specify a C-string’s maximum length in brackets immediately after it’s declared.
ANS: T PTS: 1 REF: 470

7. The close() function takes one argument.

ANS: F PTS: 1 REF: 473

8. C++ supports physical file objects.

ANS: T PTS: 1 REF: 484

9. In addition to the get() method, all input streams have a set() method for putting the last
character read from an input stream back on the stream.

ANS: F PTS: 1 REF: 484

10. When a program is executed, the standard input stream cin is connected to the standard input device.

ANS: T PTS: 1 REF: 485

MULTIPLE CHOICE

1. A ____ is a collection of data stored together under a common name, usually on a disk, magnetic tape,
USB drive, or CD/DVD.
a. file c. database
b. directory d. file stream object
ANS: A PTS: 1 REF: 462

2. Each file has a unique filename, referred to as the file’s ____.


a. storage ID c. storage name
b. external ID number d. external name
ANS: D PTS: 1 REF: 462

3. The DOS operating system allows ____ characters plus an optional period and 3-character extension
as the maximum filename length.
a. 4 c. 16
b. 8 d. 32
ANS: B PTS: 1 REF: 462

4. The Excel program adds the ____ extension automatically to all spreadsheet files.
a. .xla or .xls c. .xcl or .xclx
b. .xls or .xlsx d. .wpx or .wpxl
ANS: B PTS: 1 REF: 463

5. C++ compilers require a program file with the extension ____.


a. .c c. .cpp
b. .ccc d. .c++
ANS: C PTS: 1 REF: 463
6. A(n) ____ is a one-way transmission path used to connect a file stored on a physical device, such as a
disk or CD, to a program.
a. file stream c. stream name
b. external stream d. file name
ANS: A PTS: 1 REF: 463

7. A file stream that sends or writes data to a file is an ____.


a. input file stream c. external file stream
b. output file stream d. internal file stream
ANS: B PTS: 1 REF: 463-464

8. Input file stream objects are declared to be of type ____.


a. istream c. ifstream
b. iofstream d. ofstream
ANS: C PTS: 1 REF: 464

9. A(n) ____ is a one-way transmission path between a source and a destination.


a. file c. external name
b. object d. stream
ANS: D PTS: 1 REF: 465

10. The ____ method returns a true value if a file was opened unsuccessfully or a false value if the open
succeeded.
a. fail() c. test()
b. open() d. close()
ANS: A PTS: 1 REF: 466

11. The ____ function is a request to the operating system to end program execution immediately.
a. end() c. terminate()
b. break() d. exit()
ANS: D PTS: 1 REF: 466

12. In declaring and initializing a string variable for use in an open() method, the string is considered a
____.
a. string object c. c_str
b. C-string d. c-character
ANS: B PTS: 1 REF: 469

13. The ____ method breaks the connection between the file’s external name and the file stream object.
a. open() c. bad()
b. fail() d. close()
ANS: D PTS: 1 REF: 473

14. You must check that the ____ method established a connection between a file stream and an external
file successfully because this type of call is a request to the OS that can fail for various reasons.
a. connect() c. open()
b. conn() d. file()
ANS: C PTS: 1 REF: 474
15. C and C++ append the low-value hexadecimal byte ____ as the end-of-file (EOF) sentinel when the
file is closed.
a. 0x01 c. 0x00
b. 0x10 d. 0x11
ANS: C PTS: 1 REF: 477

16. Output file streams can be formatted in the same manner as the ____ standard output stream.
a. cout c. ccout
b. cin d. fout
ANS: A PTS: 1 REF: 478

17. The fstream class’s ____ function permits character-by-character output to a stream.
a. getline() c. putline()
b. get() d. put()
ANS: D PTS: 1 REF: 479

18. A(n) ____ file object is a stream that connects a file of logically related data, such as a data file, to a
program.
a. external c. physical
b. internal d. logical
ANS: D PTS: 1 REF: 484

19. The fstream class’s ____ function is used for character-by-character input from an input stream.
a. get() c. getchar()
b. getline() d. next()
ANS: A PTS: 1 REF: 484

20. All input streams have a ____ function for putting back the last character read from an input stream
back on the stream.
a. put() c. return()
b. putback() d. sendback()
ANS: B PTS: 1 REF: 484

21. The standard error stream is represented by ____ in C and C++.


a. cin c. cerr
b. cout d. clog
ANS: C PTS: 1 REF: 485

22. The term ____ refers to the process of retrieving data from a file.
a. file connection c. stream connection
b. file access d. stream access
ANS: B PTS: 1 REF: 487

23. The term ____ refers to the way data is stored in a file.
a. file organization c. sequential access
b. file access d. database
ANS: A PTS: 1 REF: 487
24. In ____, any character in the opened file can be read without having to sequentially read all characters
stored ahead of it first.
a. sequential access c. random access
b. sequential organization d. random organization
ANS: C PTS: 1 REF: 487

25. The ____ functions return the file position marker’s offset value.
a. offset() c. seek()
b. where() d. tell()
ANS: D PTS: 1 REF: 488

COMPLETION

1. A(n) ____________________ filename is how the operating system knows the file.

ANS: external

PTS: 1 REF: 462

2. Two basic types of files exist: text files, and ____________________ files.

ANS:
binary-based
binary

PTS: 1 REF: 463

3. A file stream that receives or reads data from a file to a program is a(n) ____________________ file
stream.

ANS: input

PTS: 1 REF: 463

4. For file streams, the direction, or mode, is defined in relation to the ____________________ and not
the file.

ANS: program

PTS: 1 REF: 464

5. For each file your program uses, a distinct ____________________ stream object must be created.

ANS: file

PTS: 1 REF: 464

6. The ___________________() method returns a false value if the file was opened successfully.

ANS: fail
PTS: 1 REF: 466

7. In using ifstream and ofstream objects, the input or output mode is indicated by the
____________________.

ANS: object

PTS: 1 REF: 471

8. In C and C++, the ___________________ sentinel is never counted as part of the file.

ANS:
EOF
eof
end-of-file
end-of-file (EOF)
end of file

PTS: 1 REF: 477

9. Reading data from a(n) ___________________-based file is almost identical to reading data from a
standard keyboard.

ANS:
character
text

PTS: 1 REF: 479

10. The standard log stream is represented by ____________________ in C and C++.

ANS: clog

PTS: 1 REF: 485

11. There are two types of file access: sequential access and ____________________ access.

ANS: random

PTS: 1 REF: 487

12. To understand file access types, first you need to understand how data is ____________________ in a
file.

ANS: organized

PTS: 1 REF: 487

13. The ____________________() methods allow the programmer to move to any position in a file.

ANS: seek
PTS: 1 REF: 488

14. Using the seek() functions in random access, a(n) ____________________ offset means move
forward in the file.

ANS: positive

PTS: 1 REF: 488

15. A file stream object may be passed to a function as long as the function’s formal parameter is defined
as a(n) ____________________ to the appropriate stream.

ANS: reference

PTS: 1 REF: 490

You might also like