In the C language, we have some special words with their set of special characters; these words are called keywords.
Keywords are reserved in C; they cannot be used for other purposes as if we cannot declare a keyword a variable or we cannot use it as a constant also
There are 32 reserved keywords in the C language. Let us have a look at some.
break | const | case | do | char | default | continue | auto |
else | float | enum | if | extern | goto | for | double |
long | short | register | static | return | sizeof | signed | int |
switch | unsigned | typeof | while | union | volatile | void | struct |
Special characters in C
In the C programming language, special characters have their special meaning, and they cannot be used for other purposes.
Some of the special characters used in c are
- #
- *
- =
- ;
- ,
- {}
- []
- ()
Preprocessor (#):
The preprocessor is used to transform the program before the compilation. Execution of the preprocessor takes place before compilation. The other name for preprocessor is “macro processor.”
The assignment operator
This operator is used to assign any value. The assignment operator is used for many purposes in the c program. We can assign the value to the variable declared.
E.g. a=10;
Here we are assigning the value 10 to the variable a.
Asterisk (*)
This special character creates a pointer variable.
Suppose we have variable a, then we can create the pointer to the variable as *a.
Semicolon (;)
You can use the semicolon to terminate the line. It is also called statement terminated in the c program; each line is ended with a semicolon.
In case we miss adding a semicolon at the end of each line in the program, then an error will be shown.
Colon (:)
This special symbol is used for the initialization of the list.
The comma (,)
If there is more than one statement, then you can use a comma to separate the statements, for example, separating parameters in function calls.
Braces{}
The opening braces to carry out some executions after finishing programming, you can use code-closing braces to close the code blocks and open the code blocks.
Parentheses()
You can use these parentheses in function parameters and in making function calls.
Brackets[]
You can use these brackets for array elements like
Single and multidimensional subscripts.
The table given below indicates the special characters and their respective meaning.
Special symbol |
Meaning |
*
~ ; |
Asterisks
Tilde semicolon |
!
$ # |
Exclamation mark
Dollar sign Number sign |
&
^ % |
Ampersand
Caret Percent sign |
)
(
|
Right parenthesis
Left parenthesis |
,
+ – |
Comma
Plus sign underscore |
.
/ \ |
Period
Slash backslash |
‘
“ |
Apostrophe
Quotation mark |
FAQs
What are keywords in C?
Keywords are predefined, reserved words used in C programming that have special meanings. These words cannot be used as identifiers (like variable names, function names, etc.) because they serve specific purposes in the language. Examples of keywords in C include int, return, if, while, for, break, continue, switch, case, default, void, and many others.
Can I define new keywords in C?
No, you cannot define new keywords in C. The set of keywords is fixed by the C standard, and only the language specifications can introduce new keywords. However, you can define macros, which can somewhat mimic the behavior of keywords, using the #define preprocessor directive.
What are some special characters used in C?
Special characters in C include symbols and punctuation marks that perform specific functions. Examples include:
{ } (curly braces) – Define the beginning and end of blocks of code, such as function bodies.
; (semicolon) – Marks the end of a statement.
# (hash) – Used for preprocessor directives like #include and #define.
// or /* */ – Used to write comments in the code.
() (parentheses) – Used in function calls and definitions, and also to enforce precedence in expressions.
[] (square brackets) – Used for array indexing.
* (asterisk) – Used to denote pointers and multiplication operations.
& (ampersand) – Used for getting the address of a variable (address operator) and also as a bitwise AND operator.
How are special characters like \n and \t used in C?
These are escape sequences in C, used to represent non-graphic characters in a readable form within string literals. For instance, \n represents a newline that moves the cursor to the next line, and \t represents a horizontal tab. Other common escape sequences include \r for carriage return, \\ for backslash, \’ for single quote, and \” for double quote.
Are there any restrictions on using special characters in identifiers?
Yes, identifiers (names of variables, functions, arrays, etc.) in C cannot include most special characters. They must begin with a letter (either uppercase or lowercase) or an underscore (_), followed by letters, digits, or underscores. Special characters like @, #, $, %, etc., are not allowed in identifiers. This restriction helps maintain clarity and avoid confusion with the syntax of the C language itself.