Complete listing of Formatting02

/* File: Formatting02.cpp
Copyright 2006, Richard G. Baldwin
Illustrates formatting output data into a table.  The
output is:

       1.5       2.200
      12.8       3.142
**********************************************************/
#include <iostream>
#include <iomanip>
using namespace std;

int main(){

  //Print the first row in the table consisting of two
  // columns.
  cout << setw(10) << setprecision(1) << fixed << 1.5;
  cout << setw(12) << setprecision(3) << fixed << 2.2
                                                   << endl;
  //Print the second row.
  cout << setw(10) << setprecision(1) << fixed << 12.78;
  cout << setw(12) << setprecision(3) << fixed << 3.14159
                                                   << endl;
  return 0;
}//end main

Listing 9