home *** CD-ROM | disk | FTP | other *** search
- /*
- simple program that returns the data sizes using the sizeof()
- operator with variables and data types.
- */
-
- #include <iostream.h>
-
- main()
-
- {
- short int aShort;
- int anInt;
- long aLong;
- char aChar;
- float aReal;
-
- cout << "Table 1. Data sizes using sizeof(variable)\n\n";
- cout << " Data type Memory used\n";
- cout << " (bytes)\n";
- cout << "------------------ -----------";
- cout << "\n short int " << sizeof(aShort);
- cout << "\n integer " << sizeof(anInt);
- cout << "\n long integer " << sizeof(aLong);
- cout << "\n character " << sizeof(aChar);
- cout << "\n float " << sizeof(aReal);
- cout << "\n\n\n\n";
-
- cout << "Table 2. Data sizes using sizeof(dataType)\n\n";
- cout << " Data type Memory used\n";
- cout << " (bytes)\n";
- cout << "------------------ -----------";
- cout << "\n short int " << sizeof(short int);
- cout << "\n integer " << sizeof(int);
- cout << "\n long integer " << sizeof(long);
- cout << "\n character " << sizeof(char);
- cout << "\n float " << sizeof(float);
- cout << "\n\n\n\n";
-
- return 0;
- }
-