home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C Programming Starter Kit 2.0
/
SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso
/
tybc4
/
out1.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1993-03-24
|
743b
|
27 lines
// 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;
}