-
Notifications
You must be signed in to change notification settings - Fork 244
Expand file tree
/
Copy path4.7.cpp
More file actions
25 lines (21 loc) · 656 Bytes
/
4.7.cpp
File metadata and controls
25 lines (21 loc) · 656 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>
#include <limits>
int main() {
// Overflow means the value computed from the variables is out of the range
// of values that the type of the variable can hold.
//
// The behaviour of overflow is undefined.
int a = std::numeric_limits<int>::max();
int b = a + 1;
int c = std::numeric_limits<int>::min();
int d = c - 1;
int e = a / 2 + 1;
int f = e * 2;
std::cout << "a = " << a << std::endl;
std::cout << "b = " << b << std::endl;
std::cout << "c = " << c << std::endl;
std::cout << "d = " << d << std::endl;
std::cout << "e = " << e << std::endl;
std::cout << "f = " << f << std::endl;
return 0;
}