C Tokens

C Tokens

C Tokens are the basic building block of C language which are constructed together to write a program.

Tokens in c language are of seven types:

  1. Delimiter
  2. Keywords
  3. Constants
  4. Identifiers
  5. Special symbols
  6. Operators


A delimiter is a unique character or a sequence of characters which signify beginning or ending of a specific statement,string or a function body.


Delimiters Uses
: Colon Useful for label
; Semicolon Terminate the statement
( ) Parenthesis Used in expression and function
[ ] Square brackets Used for array decleration
{ } Curly braces Scope of the statement or Block of a function
# Hash Pre-processor directive
, Comma Variables separator



Keywords are the predefined,reserved words in C library used in programming which have special meanings to compiler.

Keywords can not be used as name of any constant,variable or any other identifiers name.

There are 32 keywords in C language.

auto double int struct
break else long switch
case enum register typedef
char extern return union
const float short unsigned
continue for signed void
default goto sizeof volatile
do if static while


3.Constant or Literals:

A constant is any information or a data which have fixed value.Value do not change during the execution of program.

Types of constant :

3.1.Primary constant are of two types.

3.1.1.Numerical constant  are of two types. constant

It include all positive and negative number including zero.Exclude any decimal,fractional part or any other symbol.


+21  ,  23  , -5  ,  0    (these are integer constant)

+3.14  ,  23/34  ,  -7.23  ,  4.4*5.1      (these are not integer constant) constant or Float point constant :

Numbers containing decimals or we can say that a fractional part is present.

Examples:   2.5 , 4.453  ,  -2.34  , 2.0 (here 2.0 is not equal to 2 because of American Standard Code for  Information Interchange)etc


3.1.2.Character constant are of three types. Character Constants: 

It contains a single character(we can also say that a single digit, a single alphabets)   enclosed with ‘  ‘  (single quotes).

Example:  ‘  ‘ (single space is also character),  ‘a’  ,  ‘B’   , ‘9’ , ‘+’ etc  (these are real constant)

but  ‘4.0’  ,  ‘-3’   , ‘droid’  etc  (these are not real constant). Constants:

Strings are the group of characters enclosed in ”  ”  (double quotes).

Examples:  “droid”  ,  “4+2”  , “345” etc Character Constants or Escape sequences:

Backslash character constant have special meanings to compiler.List is given below.

Constants ASCII Meaning
\a 007 beep sound
\b 008 backspace
\f 012 form feed
\n 010 new line
\r 013 carriage return
\t 009 horizontal tab
\v 011 vertical tab
\’ 039 single quote
\” 034 double quote
\\ 092 backslash
\0 000 null
\? 063 question mark


3.2.Secondary constant are of six types.


3.2.2.String :







Are the names of variables , functions , arrays.They are user defined names.

Rules for naming identifiers:

  1. Identifiers consist of alphabets and digits (A-Z , a-z , 0-9 ) and underscore (_) symbol.
  2. Identifiers first name must start with alphabet or underscore.
  3. Must not contains white spaces.
  4. First letter can not be a digit.
  5. Keywords names can not be used as identifiers name.
  6. Identifiers are case sensitive.(Which means droid is different from Droid or DROID).


5.Special symbols:


, Comma & Ampersand
. Dot ^ Caret
; Semicolon * Asterisk
: Colon Minus
Apostrophe + Plus
Quotation mark < less than
! Exclamation mark > Greater than
| Vertical bar ( ) Pranthesis
/ Slash [ ] Square brackets
~ tilde % Percent
$ Dollar # Hash
? Question mark = Equal to
_ Underscore @ At the rate


6.Operators :

If multiple operators present in statement then we use precedence(priority) rule.Here in C language there is predefined priority rule for operators called operator precedence.

If there are many operator of same priority present then we use associativity.

Associativity shows the order in which they executed.

Operator Description Associativity
( )
[ ]

++ —
Parentheses (function call)
Brackets (array subscript)
Member selection via object name
Member selection via pointer
Postfix increment/decrement
++ —
+ –
! ~
Prefix increment/decrement
Unary plus/minus
Logical negation/bitwise complement
Cast (convert value to temporary value of type)
Address (of operand)
Determine size in bytes on this implementation
*  /  % Multiplication/division/modulus left-to-right
+  – Addition/subtraction left-to-right
<<  >> Bitwise shift left, Bitwise shift right left-to-right
<  <=
>  >=
Relational less than/less than or equal to
Relational greater than/greater than or equal to
==  != Relational is equal to/is not equal to left-to-right
& Bitwise AND left-to-right
^ Bitwise exclusive OR left-to-right
| Bitwise inclusive OR left-to-right
&& Logical AND left-to-right
| | Logical OR left-to-right
? : Ternary conditional right-to-left
+=  -=
*=  /=
%=  &=
^=  |=
<<=  >>=
Addition/subtraction assignment
Multiplication/division assignment
Modulus/bitwise AND assignment
Bitwise exclusive/inclusive OR assignment
Bitwise shift left/right assignment


Comma (separate expressions) left-to-right

Note 1:
Parentheses are also used to group sub-expressions to force a different precedence; such parenthetical expressions can be nested and are evaluated from inner to outer.

Note 2:
Postfix increment/decrement have high precedence, but the actual increment or decrement of the operand is delayed (to be accomplished sometime before the statement completes execution).

So in the statement y = x * z++; the current value of  z is used to evaluate the expression.


z++ evaluates to z and z only incremented after all else is done.

Leave a Reply

Your email address will not be published. Required fields are marked *