Assume that the size of char is 1 byte and negatives are stored in 2's complement form
#include<stdio.h>
int main()
{
char c = 125;
c = c+10;
printf("%d", c);
return 0;
}
How can be the answer is -121?
Assume that the size of char is 1 byte and negatives are stored in 2's complement form
#include<stdio.h>
int main()
{
char c = 125;
c = c+10;
printf("%d", c);
return 0;
}
How can be the answer is -121?
125 + 10 = 135. This is above 127, hence the addition overflows and the end result is 135 - 256 = - 121.