home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / diverses / tctnt / formioa.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-27  |  666 b   |  34 lines

  1. /* FORMIOA.CPP: Using stream manipulators, Part A
  2.  
  3.          The following program will output a grid of floating point
  4.          values with a fixed number of digits which appear to the right
  5.          of the decimal point similar to the way money is written.
  6. */
  7.  
  8. #include <iostream.h>
  9. #include <iomanip.h>
  10.  
  11. void money(float f) {
  12.     cout.setf(ios::showpoint);
  13.     cout << setw(10) <<  setprecision(2) << f;
  14. }
  15.  
  16. int main(void)
  17. {
  18.     int i;
  19.     float f;
  20.  
  21.     for ( i = 0, f = 1.50; i < 30; i++, f = f + 32.39) {
  22.         money( f );
  23.         if ( (i % 6) == 5 )
  24.             cout << endl;
  25.     }
  26.     cout << endl;
  27.     for( i = 0; i < 4; i++ )
  28.         money( i );
  29.     cout << endl;
  30.  
  31.     return 0;
  32. } // end of main()
  33.  
  34.