Integer Over Flow
At run-time, a variable may be assigned an incorrect value. The logical value of the expression b+c is 4 billion, which is greater than the maximum value which can be stored in a variable of type int. This is known as an integer overflow
int b = 2000000000, c =2000000000; a = b + c; /* out of range */
How do we fix this problem?
What if we declare:
long a, b = 2000000000, c = 3000000000; Or unsigned long a, b = 2000000000, c = 2000000000;
Support us by sharing this post