Tokens in C

Tokens in C: A token is the smallest element of the program that is meaningful to the compiler.
Tokens in C can be classified as follows:

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

Tokens in C

1. Keywords

Keywords are pre-defined (or) reserved words in a programming language. Each keyword is meant to perform specific functions in a program. And we cannot redefine the keywords. C language supports 32 keywords. They are as follows:

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

While in C++ there 31 additional keywords other than C.


float a, b;
printf("Showing how keywords are used.");
return 0;

2. Identifiers

Identifiers are nothing but used for naming variables, functions, and arrays. Identifier names must differ in spelling and case from any keywords. You cannot use Keywords as identifiers, they are reserved for special use. A special kind of identifier, called statement label, can be used in goto statements.

Rules for naming Identifiers

  • They must begin with a letter or underscore _
  • consists of only letters, digits, or underscore.
  • No other special characters are allowed.
  • They must not contain white space.
  • And should be up to 31 characters long.


int amount;
double totalbalance;

3. Constants

Constants are similar to normal variables. The only difference between them is their values cannot be modified by the program once they are defined. And constants are referred to as fixed values. They are also called as literals.

Constants are of a different type. They are as follows:

  1. Integer Constant: Ex: 0, 1, 2586, 201987
  2. Real (or) Floating point constants: Ex: 0.0, 153.56, 24896.32415
  3. Octal & Hexadecimal Constants: Ex: octal:(013)8 = (11)10,
  4. Hexadecimal:(013)16= (19)10
  5. Character constants: ‘a’, ‘A’, ‘d’
  6. String constants: Ex: “Freshersnow”

There are two ways to define constant in C programming.

  • const keyword
  • #define preprocessor

C const Keyword

The const keyword is used to define constant in programming.


int main(){    
    const float PI=3.14;    
    printf("The value of PI is: %f",PI);    
    return 0;  

The value of PI is: 3.140000

C #define preprocessor

The #define preprocessor is also used to define constant.

4. Strings

Strings are nothing but known as a sequence of characters, enclosed in double quotes, and includes letters, digits, special characters, and blank spaces. In strings, there is a difference between ” ” and ‘ ‘.


"F" -----> represents a string. 
'F' ------> represents a single character

5. Special Symbols

C language has some special symbols which can be used for different purposes like [] () {},;: * … = #

Braces { }

While The opening and ending curly braces denote the start and end of a block of code containing more than one executable statement.

Parentheses ( )

It is used to indicate function calls and function parameters.

Brackets [ ]

While the Opening and closing brackets used as array element reference. This indicates single and multi-dimensional subscripts.