previous | start

## Strings (Output Formatting)

- To format output we use the manipulators accessed by including `#include<iomanip>`.
- The `setw()` manipulator sets the field width of the next output.
- The `setprecision()` manipulator is used to set the precision of the next floating point number.
- By using the `fixed` manipulator, you ensure that trailing zeroes are displayed.
- The sequence of commands

  >     cout << fixed << setprecision(2);
  >     cout << setw(8) << pennies << " "
  >       << setw(8) << pennies * 0.01 << "\n";
  >     cout << setw(8) << nickles<< " "
  >       << setw(8) << nickles * 0.05<< "\n";
  >     cout << setw(8) << dimes<< " "
  >       << setw(8) << dimes * 0.1 << "\n";
  >     cout << setw(8) << quarters<< " "
  >       << setw(8) << quarters * 0.25 << "\n";

  creates the table

  >           1     0.01
  >           12     0.60
  >            4     0.40
  >          120    30.00

previous | start