Keywords and Identifiers

C language character set #

In C language you can use the following characters.

Alphabets

a, b, c, ... z
A, B, C, ... Z

Digits

0,1,2,3,4,5,6,7,8,9

Special Symbols

The following table shows some special characters used extensively in C.

Character Meaning
+ Plus Sign
- Minus Sign
* Multiplication
/ Division
% Percent Sign or modulus operator
() Parentheses
{} Curly braces
[] Square brackets
= Equal Sign
, comma
; Semicolon
: colon
' Single quote
" Double quote
? Question mark
. Period or dot symbol
# Hash
^ Caret symbol
~ Tilde
! Exclamation mark
& ampersand
| pipe character

Escape Sequences #

Escape Sequences are used to print some special characters in the console which can't be printed by directly using the keyboard such as newline, tab etc. Escape Sequences consists of 2 or more characters, the first character is \ and the second character varies according to the need. Here are some common escape sequences.

Escape Sequence Meaning What it does ?
\n newline \n character moves the cursor to the beginning of the next line
\t tab \t character moves the to the next tab stop
\b backspace \b character moves the cursor back to the previous position
\r carriage return \r character moves the cursor to the beginning of the current line
\a bell(alert) \a character produces a beep sound
\\ backslash \\ character is used to print single backslash (\) character
\0 null \0 character denotes a null character
\' single quote \' character is used to print single quote(')
\" double quote \" character is used to print double quote(")

Note: newline (\n), backspace (\b), Carriage return (\r), tab (\t), space ( ) are known as whitespace characters.

Keywords #

Keywords are some reserved words that C language use for denoting something specific. In C Keywords are written in lowercase. C has only 32 Keywords.

keywords-in-c

Identifiers #

Identifiers are the words we use to name entities like variables, functions, array, structure, symbolic constant etc.

The rules for naming identifiers are as follows:

  1. Identifiers must consist of alphabets, digits or underscores (_) only.
  2. The first character should be an alphabet or underscore (_).
  3. The identifier should not be a keyword.
  4. Identifiers can be of any length.

C is case-sensitive language so my_var and MY_VAR are two distinct identifiers.

Some examples of valid identifiers:

num , _address , user_name , email_1

Examples of invalid identifiers:

1digit – an identifier must not start with a number
my var – an identifier must not contain space between names
intint is a keyword
some# – pound(#) character is not allowed