Page 1 of 1

5. Which of the following sets of statements will set floating point output to the stream outStream to fixed point with

Posted: Fri Apr 29, 2022 6:50 am
by answerhappygod
5. Which of the following sets of statements will set floating
point output to the stream outStream to fixed point with set 3
places of decimals? In the explanation, you must give any necessary
#include directives and using directives or declarations.
a) outStream.setf(ios::fixed); outStream.setf(ios::showpoint);
outStream.precision(2);
b) outStream.setf(ios::fixed | ios::showpoint); outStream
<< setprecision(2);
c) outStream << setflag(ios::fixed); outStream <<
setflag(ios::showpoint); outStream << setprecision(2);
d) outStream.flags(ios::fixed); outStream.flags(ios::showpoint);
outStream.precision(2);
7.To clear the show plus sign flag but leave the rest of the
flags alone, you use the _____________ member function and
argument.
e) setf(! ios::showpos);
f) setprecision(ios::showpos);
g) unsetf(ios::showpos);
h) setf(ios::showneg);
i) unsetf(! ios::showneg);
8.To determine whether a file was opened successfully, one can
use the ___________ fstream member function
j) close( )
k) overloaded operator <<( )
l) open( )
m) eof( )
n) flush( )
9-The ____________ fstream member function closes a file stream.
Explain why it is best to close a file when the program is through
processing the data in the file.
o) close( )
p) overloaded operator <<( ) open( )
q) eof( )
r) flush( )
10-The _______ member function takes a single char value from
the input file, without regard to whether it is whitespace.
s) newLine
t) get
u) put
v) getline
w) putline