In this lesson, we will talk about allowed characters, numbers, special symbols, keywords and identifiers in C Programming.
Character Set in C Programming
C supports a wide range of Characters (256) which can be used for various purposes. The entire character set is divided into 2 parts i.e. the ASCII characters set and the extended ASCII characters set. An extensive list of all of these is given below:
C supports the English alphabets in both lower and upper cases. We should also keep in mind that C is a case sensitive language. This means that
"A" are not the same and will be treated differently by the C compiler.
|Supported Alphabets in C Language|
|a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z|
|A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z|
|Supported Numbers in C Language|
|0, 1, 2, 3, 4, 5, 6, 7, 8, 9|
Below list shows the special symbols used extensively in C language:
|Plus Sign||Used for Arithmetic Operations, Increment Operator|
|Minus Sign||Used for Arithmetic Operations, Decrement Operator|
|Multiplication Sign||Used for Arithmetic Operations, Pointers|
|Division Sign||Used for Arithmetic Operations|
|Percentage / Modulus||Used for Arithmetic Operations|
|Parenthesis||Used in Function Declarations|
|Curly Braces||Used in Function/Strucuture Body|
|Square Brackets||Used in Arrays|
|Equal To Sign||Used for Arithmetic Operations, Assignment Operator|
|Comma||Used during Multiple Declarations|
|Semicolon||Used to Terminate Statements|
|Colon||Used in Bit-Fields|
|Single Quotes||Used in Character Variable Declaration|
|Double Quoted||Used in String Declaration|
|Question Mark||Used in Ternary Operator|
|Period / Dot||Used in Member Selection via Object Name|
|Hash Sign||Used in Preprocessor Directive Declaration|
|Caret Sign||Used for Arithmetic and Logical Operations|
|Tilde Sign||Used for Logical Operations|
|Exclamation Mark||Used for Logical Operations|
|Ampersand Sign||Used for Logical Operations|
|Pipe Sign||Used for Logical Operations|
Escape Sequences in C Programming
Escape Sequences are characters that do not fall directly into the 256 Character set, supported by C. They do not represent themselves when used inside a string and are difficult or impossible to be represented directly. What this means is these special characters can’t be printed directly using the keyboard. An Escape Sequence always starts with the backslash character
\ followed by a particular escape character. The below table gives a detailed list of all Escape Sequences supported in the C language:
|Newline||Used to move the cursor to the beginning of a new line|
|Tab||Used to move the cursor to the next Tab stop|
|Backspace||Used to move the cursor back by one space on the current line|
|Carriage Return||Used to move the cursor to the beginning of the current line|
|Bell(alert)||Used to produce a beep sound from the system|
|Backslash||Used to print the Backslash (|
|Null||Denotes a null character|
|Single Quote||Used to print the Single Quote (|
|Double Quote||Used to print the Double Quote (|
\n), Tab (
\t), Backspace (
\b) and Carriage Return(
\r) are also known as Whitespace characters.
Keywords and Identifiers in C Programming
Keywords are reserved words that have special meaning to the C compiler. They are used in the C language for denoting something specific and can not be declared as Identifiers. In C, Keywords are written in lowercase. Originally C had only 32 Keywords but they have been increased with newer C standards.
2 Keywords introduced in ISO C11.
a Starting in Visual Studio 2019 version 16.8, these keywords are supported in code compiled as C when the
/std:c17compiler options are specified.
b Starting in Visual Studio 2019 version 16.8, these keywords are recognized but not supported by the compiler in code compiled as C when the
/std:c17compiler options are specified.
Identifiers are user given names to various C entities such as variables, functions, array, structure, symbolic constant etc. Identifiers are used extensively by the Programmer to access various entities of the C language. There are strict rules in C for naming these entities. These rules have been mentioned below:
- Identifiers can only have alphanumeric characters (
0-9) and underscore (
_) only in their name.
- Identifier names must be unique. No two Identifiers in the same program can have the same name.
- The first character of an Identifier must be an alphabet or the underscore (
_). Numbers are not allowed in the first character.
- The Identifier name can’t be the same as that of a Keyword.
- Identifiers are case-sensitive.
- There must not be white spaces inside the Identifier name.
Valid Examples of Identifier Names
- Identifiers with only alphabets:
- Identifiers with alphabets and numbers:
- Identifiers with underscore:
Invalid Examples of Identifier Names
- Identifiers starting with Numbers:
- Use of space between alphabets and numbers:
- Use of special symbols: