BCA Sem 1 | Unit 1 | Computer Concepts & C Programming
C Character Set
Letters, Digits, Special Symbols, and Escape Sequences — The Fundamental Building Blocks of C
When you write any program in C, the compiler groups every character into one of four primary categories:
Letters (Alphabets)
Uppercase (A to Z) and Lowercase (a to z). C treats uppercase and lowercase differently.
Digits
Decimal digits from 0 through 9 used to form numbers, constants, and literal values.
Special Symbols
Punctuation and mathematical symbols used for operations, syntax blocks, and macros.
Non-Printable Characters Recognized by C Compiler
Here is the detailed breakdown of all characters accepted by C compilers along with their roles:
| Category | Characters Included | ASCII Range | Usage in C Program |
|---|---|---|---|
Uppercase Letters | A, B, C, ... Z | 65 to 90 | Macros, Constants, Identifiers |
Lowercase Letters | a, b, c, ... z | 97 to 122 | Keywords, Variable names, Function names |
Decimal Digits | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 | 48 to 57 | Literals, Numbers, Array indices |
Special Symbols | , . ; : ? ' " ! # % & * - + = < > ( ) [ ] { } ^ | / \ ~ $ @ _ | Various ASCII | Operators, Delimiters, Punctuation |
White Space | Blank Space, Horizontal Tab (\t), Carriage Return (\r), New Line (\n), Form Feed | 32 (Space), 9 (\t), 10 (\n) | Separates tokens, ignored by compiler (except in strings) |
'A' has ASCII value 65, while 'a' has ASCII value 97.
( )Parentheses: Function arguments & priority{ }Curly Braces: Code block boundaries[ ]Square Brackets: Array dimension / indexing;Semicolon: Statement terminator
+ - * / %Arithmetic operations&Address-of operator & Bitwise AND*Pointer dereference & Multiplication= == !=Assignment and Comparison
#Preprocessor directive (e.g.#include)_Underscore: Only special character allowed in variable names\Backslash: Starts escape sequences
Observe how different categories of characters work together in a simple C code snippet:
_ is special because C treats it like an alphabet! That means variable names can start with or contain underscores (e.g., _total_mark).
Reading Raw Source Code
The compiler scans the .c text file character-by-character from top to bottom.
Filtering White Spaces & Comments
Extra spaces, tabs, newline characters, and comments are filtered out (except inside quoted strings).
Token Formation
Valid characters are grouped together to form C Tokens (Keywords, Identifiers, Operators, Constants).
'A' (ASCII 65) is NOT equal to 'a' (ASCII 97). Therefore, variable names Total, TOTAL, and total are three separate variables!
- Definition: C Character Set is the set of letters, digits, and special characters valid in C language.
- 4 Categories: Alphabets (A-Z, a-z), Digits (0-9), Special Symbols, White spaces.
- ASCII Encoding: Each character has a unique integer ASCII value (e.g., 'A' = 65, 'a' = 97, '0' = 48).
- Case Sensitivity: Uppercase and lowercase characters are distinct and non-interchangeable.
- Underscore Exception:
_is the only special symbol allowed inside variable identifiers. - White Spaces: Space, Tab (
\t), Newline (\n), Carriage return (\r) separate tokens. - Escape Sequences: Special two-character combinations starting with
\(e.g.,\n,\t,\0).