Understanding the character set of the C language is essential because every program you write uses these characters. A character set includes letters, digits, special symbols, and white spaces that are recognized by the C compiler. These characters are the building blocks for writing identifiers, keywords, operators, constants, and more.
C follows the ASCII (American Standard Code for Information Interchange) standard, meaning each character corresponds to a numeric code internally.
1. Alphabets
C supports both uppercase and lowercase English letters.
Uppercase Letters
A B C D ... X Y Z
Lowercase Letters
a b c d ... x y z
Note: Uppercase and lowercase letters are considered different in C (case-sensitive).
Example:
int Max = 10;
int max = 20;
printf("%d", max); // Outputs 20, not 10
Here, Max and max are treated as different identifiers.
2. Digits
C allows the following digits:
0 1 2 3 4 5 6 7 8 9
Digits are used to form numeric constants and are part of identifiers (but cannot be the first character of an identifier).
Example:
Valid identifiers:
value1
marks2025
Invalid:
1value // ❌ cannot start with a digit
3. Special Characters
C programs use many special symbols. These symbols help form operators, punctuations, and structure of the program.
Common Special Characters
| Character | Purpose |
|---|---|
+ | Addition operator |
- | Subtraction |
* | Multiplication |
/ | Division |
% | Modulus |
= | Assignment |
> < | Comparison |
& ` | !` |
# | Preprocessor |
; | Statement terminator |
, | Separator |
() | Function call or grouping |
{} | Blocks |
[] | Arrays |
" | String constant |
' | Character constant |
4. White Spaces
Whitespace characters separate tokens and improve readability. They are ignored by the compiler unless they appear in string or character literals.
Types of Whitespace:
- Space
- Tab (
\t) - Newline (
\n) - Carriage return
- Form feed
Example:
int a = 10;
The spaces do not affect how the program runs.
5. Escape Sequences
These are special characters represented using a backslash.
Common Escape Sequences
| Sequence | Meaning |
|---|---|
\n | Newline |
\t | Tab |
\\ | Backslash |
\" | Double quote |
\' | Single quote |
Example:
printf("Hello\nWorld");
Output:
Hello
World
6. Characters and ASCII Values
Every character in C has a numeric ASCII code.
Example:
printf("%d", 'A'); // Output: 65
ASCII values are used internally for sorting, comparison, and encoding.
7. Summary
The character set in C consists of:
- Alphabets (A–Z, a–z)
- Digits (0–9)
- Special characters (+, -, *, /, #, :, ;, etc.)
- Whitespace characters
- Escape sequences
These characters form the basis of all C programs, enabling developers to write valid syntax and structured logic.
🔗 View other articles about C Programming:
https://savanka.com/category/learn/c-programming