Data Types in C Language (Part 2)
Data Types in C Language
Char Data Type used in C
In C programming, the char data type is a data type that represents a single character. It is an integer data type
that is typically stored in a single byte of memory and can represent any character in the ASCII character set,
which includes the letters of the alphabet (both uppercase and lowercase), digits, punctuation marks, and special
characters such as ‘\n’ (newline) and
‘\0’ (null character).
The Char data type is divided into two types:
Signed Data Type
• It stores both positive and negative values so it ranges from -128 to +127.
Unsigned Data Type
• It stores only positive values so it ranges from 0 to 255.
You can also use the char data type to store strings of characters. In C, a string is simply an array of characters
that is terminated by a special character called the null character, which is represented by the ‘\0’ character.
Character Data Type used in C
Declaration of Character type variable
Syntax:
Data Type <Name>;
Example:
char character;
Char x;
Char x, y, z;
Character Data Type used in C
Initialization of Character type variable
A character type variable can be initialized in two ways as follows:
1. By assigning value to a variable using assignment operator.
character = 'A';
2. By assigning value to a variable during declaration only using an assignment operator.
char character = 'A';
Primitive/Primary Data Types