quiz2b - setprecision & setw

Name ________________________________     Date _________

Determine the output.  Show your work.

#include <iostream.h> //cin and cout
#include <iomanip.h> // setw , setprecision, unsetf

main()
{
float x = -12.2565;
float y = 2.7452367;
int k = 315;
int j;

cout << x << '\n';
cout << y << '\n';
cout << "***\n";
k = k + 5;

//activating decimal display
cout.setf(ios::showpoint);

//Use boxes to display your output
cout << setprecision (4) << setw(8)<< x << '\n';
cout << "123456789\n";
cout << setw (5) << k << '\n';

cout << setprecision (6) << setw(10) << y << '\n';
cout << "123456789\n";
j = k * 2 + k + -3;
cout << setw(7) << j << '\n';
cout << x << '\n';
cout << y << '\n';
cout << "***\n";

//deactivating decimal display. 
cout.unsetf(ios::showpoint);

cout << x << '\n';
cout << y << '\n';

return 0;
}

Output                                                        Work

-12.2565
2.74524
***
   -12.26
123456789
   320
    2.74524
123456789
     957
-12.2565
2.74524
***
-12.2565
2.74524