// Purpose: A program to demonstrate the various sizes of fundamental object types // Author: Keith Shomper // Date: 9/12/03 #include using namespace std; int main () { // The following 10 output statements print the size of the associated fundamental // types. Also take note of the use of the escape sequence for 'tab' cout << "Integer objects:" << endl; cout << " The size of a 'short' is: " << sizeof(short) << " bytes." << endl; cout << "\tThe size of an 'int' is: " << sizeof(int) << " bytes." << endl; cout << "\tThe size of a 'long' is: " << sizeof(long) << " bytes." << endl << endl; cout << "Float objects:" << endl; cout << "\tThe size of a 'float' is: " << sizeof(float) << " bytes." << endl; cout << "\tThe size of a 'double' is: " << sizeof(double) << " bytes." << endl; cout << "\tThe size of a 'long double' is: " << sizeof(long double) << " bytes." << endl << endl; cout << "Char objects:" << endl; cout << "\tThe size of a 'char' is: " << sizeof(char) << " byte.\n\n" << endl; // This code segment shows the result of assigning an integer to a short when the // short is too small to hold the value int x = 65537; short y; y = x; cout << "The value of x is: " << x << endl; cout << "The value of y is: " << y << endl; return 0; }