**Allocation and Storage part of C programming **
I have come with some doubt while trying to print negative numbers through different number system. while printing negative numbers, I am getting different output values.But I am not understanding clearly. If anybody help me will be appreciative.
#include<stdio.h>
int main( )
{
char a = -5;
unsigned char b = -5;
int c = -5;
unsigned int d = -5;
//try to print as using "%d" format specifier to display decimal value
printf("%d %d",a,b);
printf("%d %d",c,d);
//try to print as using "%o" format specifier to display octal value
printf("%o %o",a,b);
printf("%o %o",c,d);
//try to print as using "%x" format specifier to display hexa-decimal value
printf("%x %x",a,b);
printf("%x %x",c,d);
return 0;
}
Output:-
displaying decimal value
a = -5 b = 251
c = -5 d = -5
displaying octal value
a = 37777777773 b = 373
c = 37777777773 d = 37777777773
displaying Hexa-decimal value
a = fffffffb b = fb
c = fffffffb d = fffffffb
Now, come to the point. I don't know why unsigned char would take only 8 bits(1 Byte) and other gets allocated to 32 bits (4 Bytes).