// integer_types.cpp
#include <iostream>
#include <climits> // climits is a header file containing
// the constants INT_MAX, etc., which tell us
// the most extreme possible values of the
// integer data types.
int main() {
// Table column headings:
cout << "Data type Lowest value Highest value"
<< " Bytes Bits" << endl << endl;
// int and unsigned int:
const int INT_SIZE = sizeof(int); // how many bytes in an int
cout << "int " << INT_MIN
<< " " << INT_MAX
<< " " << INT_SIZE << " "
<< (8 * INT_SIZE) << endl;
const int UINT_SIZE = sizeof(unsigned int); // bytes in unsigned int
cout << "unsigned int " << 0
<< " " << UINT_MAX
<< " " << UINT_SIZE << " "
<< (8 * UINT_SIZE) << endl;
// long and unsigned long:
const int LONG_SIZE = sizeof(long); // how many bytes in a long
cout << "long " << LONG_MIN
<< " " << LONG_MAX
<< " " << LONG_SIZE << " "
<< (8 * LONG_SIZE) << endl;
const int ULONG_SIZE = sizeof(unsigned long); // bytes unsigned long
cout << "unsigned long " << 0
<< " " << ULONG_MAX
<< " " << ULONG_SIZE << " "
<< (8 * ULONG_SIZE) << endl;
// short and unsigned short:
const int SHORT_SIZE = sizeof(short); // how many bytes in a short
cout << "short " << SHRT_MIN
<< " " << SHRT_MAX
<< " " << SHORT_SIZE << " "
<< (8 * SHORT_SIZE) << endl;
const int USHORT_SIZE = sizeof(unsigned short); // bytes unsigned short
cout << "unsigned short " << 0
<< " " << USHRT_MAX
<< " " << USHORT_SIZE << " "
<< (8 * USHORT_SIZE) << endl;
// char, signed char, and unsigned char
const int CHAR_SIZE = sizeof(char); // how many bytes in a char
cout << "char " << (int) CHAR_MIN
<< " " << (int) CHAR_MAX
<< " " << CHAR_SIZE << " "
<< (8 * CHAR_SIZE) << endl;
const int SCHAR_SIZE = sizeof(signed char); // bytes signed char
cout << "signed char " << (int) SCHAR_MIN
<< " " << (int) SCHAR_MAX
<< " " << SCHAR_SIZE << " "
<< (8 * SCHAR_SIZE) << endl;
const int UCHAR_SIZE = sizeof(unsigned char); // bytes unsigned char
cout << "unsigned char " << 0
<< " " << UCHAR_MAX
<< " " << UCHAR_SIZE << " "
<< (8 * UCHAR_SIZE) << endl;
return 0;
} // function main