Character data type:
- ‘char’ is the keyword used to declare character data type in C program.
- Using char data type, we can store alphabets, digits and special symbols.
- We must specify the character using single quotes.
- “%c” is the format specifier to display the symbols.
#include <stdio.h>
int main()
{
char v1 = 'a';
char v2 = '5';
char v3 = '$';
printf("v1 value is : %c \n", v1);
printf("v2 value is : %c \n", v2);
printf("v3 value is : %c \n", v3);
return 0;
}
Output:
v1 value is : a
v2 value is : 5
v3 value is : $
Memory representation:
- In computer, memory always represents in bytes.
- Byte equals to 8 bits.
- Binary information will store as bits into memory
- The minimum and maximum values we can store into byte as follows:
How computer stores symbols and alphabets into memory?
- Every symbol or alphabet or digit will be automatically converted into binary value using character system.