Char Data Types

char data type occupies one byte in memory. By default char is signed. A signed char has a range of value between -128 to +127, unsigned char on the other hand has a range from 0 to 255.
Let us see the result of unsigned char and signed char with the following:
Example:
main()
{
unsigned char ch1;
char ch2;
ch1=224;
ch2=125;
printf("Character ch1=%c\t Ascii value=%d",ch1,ch1);
printf("Character ch2=%c\t Ascii value=%d",ch2,ch2);
}
The output of the program:
Character ch1=@ Ascii value=224
Character ch2=} Ascii value=125

No comments:

Post a Comment