// demonstrate overflow error of int variables #include #include using namespace std; int n, n1, n2; int main() { n = 2147483647; n1 = n + 1; // value too large, overflow occurs n2 = -n -2; // value too negative, overflow occurs cout << n << ' ' << n1 << ' ' << n2 << endl; }