#include #include // Needed for the limits for data types using namespace std; int main() { short i; cout << "sizeof( short ) = " << sizeof( i ) << "\n"; cout << "Range of short type: " << SHRT_MIN << " to " << SHRT_MAX << "\n"; // This gives bad results because of integer overflow! i = SHRT_MAX + 1; cout << "Overflow: SHRT_MAX + 1 is not " << i << "\n\n"; int j; cout << "sizeof( int ) = " << sizeof( j ) << "\n"; cout << "Range of int type: " << INT_MIN << " to " << INT_MAX << "\n"; // This gives bad results because of integer underflow! j = INT_MIN - 1; cout << "Underflow: INT_MIN - 1 is not " << j << "\n\n"; long k; cout << "sizeof( long ) = " << sizeof( k ) << "\n"; cout << "Range of long type: " << LONG_MIN << " to " << LONG_MAX << "\n"; // This gives bad results because of integer overflow! k = LONG_MAX + 1; cout << "Overflow: LONG_MAX + 1 is not " << k << "\n\n"; unsigned short l; cout << "sizeof( unsigned short ) = " << sizeof( l ) << "\n"; cout << "Range of unsigned short type: " << 0 << " to " << USHRT_MAX << "\n\n"; unsigned int m; cout << "sizeof( unsigned int ) = " << sizeof( m ) << "\n"; cout << "Range of unsigned int type: " << 0 << " to " << UINT_MAX << "\n\n"; unsigned long n; cout << "sizeof( unsigned long ) = " << sizeof( n ) << "\n"; cout << "Range of unsigned long type: " << 0 << " to " << ULONG_MAX << "\n\n"; cout << "\n\n"; system( "PAUSE" ); // system( "PAUSE" ) is system dependent return( 0 ); }