main()
{
char a,b,c;
a=6;
b=-5;
c = a+b ;
printf (“%d %d %d \n” , a, b,c ) ;
}
Here , what actually happens 00000110 10000101 -------- 10000111 -------- So values c will -11 , then how come it is 1.
Your error is: -5 in two’s complement is not
10000101. In 32-bit it is:111111111111111111111111111110116, is:
00000000000000000000000000000110The sum is:
I recommend you read this Wikipedia page about signed number representation. Modern CPUs use two’s complement.