// Author: Suzuki // created on Friday, April 25, 2003 // please send comments to ricardo_suzuki@yahoo.com // // // This program shows the usage of the sizeof // operator and the built-in constants // that can be used to find the limits // for the different types of data #include #include #include using namespace std; void main() { cout << "Maximum signed char: " << CHAR_MAX << endl; cout << "Minimum signed char: " << CHAR_MIN << endl; cout << "Maximum unsigned char: " << UCHAR_MAX << endl << endl; system("pause"); cout << "Maximum signed short: " << SHRT_MAX << endl; cout << "Minimum signed short: " << SHRT_MIN << endl; cout << "Maximum unsigned short: " << USHRT_MAX << endl; cout << "Minimum unsigned short: " << 0 << endl << endl; system("pause"); cout << "Maximum signed integer: " << INT_MAX << endl; cout << "Minimum signed integer: " << INT_MIN << endl; cout << "Maximum unsigned integer: " << UINT_MAX << endl; cout << "Minimum unsigned integer: " << 0 << endl << endl; system("pause"); cout << "Maximum signed long: " << LONG_MAX << endl; cout << "Minimum signed long: " << LONG_MIN << endl; cout << "Maximum unsigned long: " << ULONG_MAX << endl; cout << "Minimum unsigned long: " << 0 << endl << endl; system("pause"); cout << "Maximum positive float: " << FLT_MAX << endl; cout << "Minimum positive float: " << FLT_MIN << endl << endl; system("pause"); cout << "Maximum positive double: " << DBL_MAX << endl; cout << "Minimum positive double: " << DBL_MIN << endl << endl; system("pause"); cout << "Size of char: " << sizeof(char) << endl; cout << "Size of short: " << sizeof(short) << endl; cout << "Size of int: " << sizeof(int) << endl; cout << "Size of long: " << sizeof(long) << endl << endl; system("pause"); cout << "Size of unsigned char: " << sizeof(unsigned char) << endl; cout << "Size of unsigned short: " << sizeof(unsigned short) << endl; cout << "Size of unsigned int: " << sizeof(unsigned int) << endl; cout << "Size of unsigned long: " << sizeof(unsigned long) << endl << endl; system("pause"); cout << "Size of boolean: " << sizeof(bool) << endl << endl; cout << "Size of float: " << sizeof(double) << endl; cout << "Size of double: " << sizeof(double) << endl; cout << "Size of long double: " << sizeof(long double) << endl << endl; }