Tokens in C

Filed Under: C Programming

Smallest units of programming language are called Tokens. These are building blocks of programming language which can not be divided further. Tokens in C are case sensitive.

Tokens in C – Easy Definition

In simple words, Tokens for programming languages are same as Alphabets, Numbers, Symbols to English or any general language.

Token Types

There are 5 types of tokens in programming language. Any smallest unit of a program belongs to either of these 5 tokens.

Tokens in C

Tokens in C

1. Keywords

Reserved words in programming language are keywords having their meaning defined in the compiler.

  • They are replaced by their definition(meaning) when program is compiled.
  • They can not be used as variables (Identifiers).
  • E.g. if, int, while

2. Identifiers

These are user defined names in a program. Identifier is a name(reference) given to some entity in a program, also known as variable.

There are some rules to define a variable:

  • It can not be a keyword.
  • It can not start with digit.
  • Valid characters for a identifier are combination of “0-9”, “A-Z”, “a-z” and “_”(underscore)
  • It can not contain any special character, e.g. ‘@’,’#’,’$’ etc.
  • Valid Identifier: student_1, noOfApples etc.
  • Invalid Identifier: 1_student, Apple$price etc.

3. Literals

These are constant values in program. Integers, floating point numbers such as 23, 104.88 etc. are literals.

E.g. “Twenty Three” 23 means “Twenty Three” only and it can not have some other meaning or value. We’ll learn more about literals in further lessons.

4. Operators

Operators are symbols which perform operation on operands. e.g. ‘+’,’%’,’&’,’=’ etc.
We are going to classify commonly used operators in 2 ways:

Based on number of Operands

  1. Unary Operators: These perform operation on single operand.
  2. Binary Operators: These perform operation on two operands.
  3. Ternary operator:It performs operation on three operands.

Based on Types of Operator

  1. Arithmetic Operators: perform arithmetic operations like Add +, Subtract , Divide /, Multiply *, Mod %
  2. Logical Operators: AND &, OR |, NOT !
  3. Relational operators: compare two operands and tells whether the result is true(1) or false(0).
    e.g. <   >   <=   >=   ==   !=

We will be doing a detailed discussion of operators and their uses in various scenarios with upcoming articles.

5. Punctuators

These are special symbols which tells something to the compiler. As in English, we have”Full Stop”,
“Commas” etc. to let reader know where the sentence ends or has a pause, similarly punctuators works for compiler in same way. e.g. { } ; . () etc.


Tokens are the building blocks of any programming language. There are different types of tokens and they are processed according to their specific processing rules. We learned about the five different types of tokens in the C Programming language. We will look into them in more detail in upcoming C tutorials.

Leave a Reply


Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages