home *** CD-ROM | disk | FTP | other *** search
- // Program illustrates C++ formatted stream output
- // using the width and precision functions
-
- #include <iostream.h>
-
- main()
- {
- short aShort = 4;
- int anInt = 67;
- unsigned char aByte = 128;
- char aChar = '@';
- float aSingle = 355.0;
- double aDouble = 1.130e+002;
- // display sample expressions
- cout.width(3); cout << int(aByte) << " + ";
- cout.width(2); cout << anInt << " = ";
- cout.width(3); cout << (aByte + anInt) << '\n';
-
- cout.precision(4); cout << aSingle << " / ";
- cout.precision(4); cout << aDouble << " = ";
- cout.precision(5); cout << (aSingle / aDouble) << '\n';
-
- cout << "The character in variable aChar is "
- << aChar << '\n';
- return 0;
- }
-