Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdexcept>
- using std::cout; using std::endl;
- int main() {
- try {
- int a = std::pow(2, 31) - 1;
- cout << a << endl;
- int b = 1;
- int c = a + b;
- cout << c << endl;
- } catch (std::overflow_error ex) {
- cout << ex.what() << endl;
- }
- return 0;
- }
- 2147483647
- -2147483648
Add Comment
Please, Sign In to add comment