I declared a float variable, say a
, then I assigned 57.00 to it. When I wanted to print the 'a' using cout object, the stream seemed to print only 57 without the decimal point.
So, the solution to making the decimal point printed is adding showpoint manipulator after cout. Example: cout << showpoint << fixed << setprecision(2) << a << endl;
The function setprecision here is used together with fixed to specify the number of digits to be printed after the decimal point. After googling for a while, I found that showpoint and fixed are a part of <ios>
header file.
So, why don't we have to import this header? Without importing it, the code worked just fine.
And importing <iostream>
is all I need to make these stream manipulators worked as intended.
Is <ios>
header automatically imported whenever and wherever the <iostream>
header is imported?