const int X = 3; const unsigned short Y = 5; ... long grossPay; int bonusPay = -4; unsigned char netPay = 3;
int x=0x1F; cout << "X is " << x << endl; x = 010; cout << "X is " << x << endl; output: X is 31 X is 8
#include <limits.h> cout << "The maximum integer is " << INT_MAX << endl;
#include <iostream> #include <limits.h> using namespace std; int main () { int x; cout << "The maximum integer is " << INT_MAX << endl; x = INT_MAX + 1; cout << "one more is " << x << endl; return -1; } WHEN COMPILED: foo.C: In function `int main()': foo.C:12: warning: integer overflow in expression PRODUCES: The maximum integer is 2147483647 one more is -2147483648
float x; x = -1; cout << "X is " << x << endl; x = .2; cout << "X is " << x << endl; x = -.3E22; cout << "X is " << x << endl; x = -1.2E-12; cout << "X is " << x << endl; Output: X is -1 X is 0.2 X is -3e+21 X is -1.2e-12