// overflow_integer_division.cpp #include #include using namespace std; int main() { int num1 = 9; // an int variable used to illustrate integer division & type casting int num2 = 2; // an int variable used to illustrate integer division & type casting double num3 = 0.0; // a double variable used to illustrate integer division int salary = 999999999999999999; // overflow double radius = 1.00000000000000000077; // underflow num3 = num1 / num2; // integer division cout << "integer division causes 9 / 2 = " << num3 << endl; num3 = num1 / double (num2); // type casting the variable num2 to avoid integer division cout << "by type casting, we avoid integer division and 9 /2 = " << num3 << endl; cout << "trying to store a very large value in an int variable results in overflow: " << salary << endl; cout << "underflow occurs since .00000000000000000077 is too small: " << radius - 1 << endl; system("pause"); return 0; }// end of main