home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C Programming Starter Kit 2.0
/
SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso
/
tybc4
/
out2.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1993-03-24
|
1KB
|
30 lines
// C++ program uses the printf function for formatted output
#include <stdio.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
printf("%3d %c %2d = %3d\n",
aByte, '+', anInt, aByte + anInt);
printf("Output uses the %%lf format\n");
printf("%6.4f / %6.4lf = %7.5lf\n", aSingle, aDouble,
aSingle / aDouble);
printf("Output uses the %%le format\n");
printf("%6.4e / %6.4le = %7.5le\n", aSingle, aDouble,
aSingle / aDouble);
printf("Output uses the %%lg format\n");
printf("%6.4g / %6.4lg = %7.5lg\n", aSingle, aDouble,
aSingle / aDouble);
printf("The character in variable aChar is %c\n", aChar);
printf("The ASCII code of %c is %d\n", aChar, aChar);
return 0;
}