Tokens, Identifiers and Keywords in c programming language

Tokens in C

In this lesson we will discuss about Token in c program,identifiers and Keywords.

 

Every language has its own character set . like this C also has its own character set. A program is a set of instructions that generate an output after execution. The data that is processed by a program consists of various characters and symbols. The output generated is also a combination of characters and symbols. We can not create a sentence without using words; like this , we cannot create a program in c without using tokens. So we can say ,

In C programming language Token is the key and smallest individual unit which is meaningful to the compiler.

Or , C tokes are the basic buildings blocks in C language which constructed together to write a c program.

 

Classification of tokens in C programming language -

A token is divided into six different types,

  •   Keyword
  •   Identifiers
  •   String  
  •   Operators
  •   Constant
  •   Special characters
 

Tokens, Identifiers and Keywords in c programming language

For example -

 

Int main()

{

 

   Int x,y,total;

x=10, y = 20 ;

total = x + y ;

Printf(“total = %d”,total);

}

 

Here,

Main - Identifier

{,},(,) = Delimiter

Int = keyword

X,y,total = identifier

Main,{,},(,) int,x,y,total = tokens

 

Keywords

  • Keywords are predefined, reserved words in C and each of which is associated with specific features. 
  • As keywords are reserved, so they have fixed meaning and the meaning can not be changed.
  • These words help us to use the functionality of C language.
  • They have special meaning to the compilers.
  • They cant be used as variable name.
  • C language supports 32 keywords only.
  •  Keywords are written in lowercase letters.

 

Name of the keyword -

 
Tokens, Identifiers and Keywords in c programming language

Identifiers

Each program element in C programming language is known as an identifier. They are used as the general terminology for the names givens to different parts of the program like variable, functions, array etc. These are used defined names which consist of alphabets, number, underscore(“_”) . Identifiers name should not be same or same as keyword. Keywords are not as used as identifiers. An identifier is used to identify elements of a program.

 

Some feature of identifiers

  • The first character should be an alphabet or underscore.
  • It should not begin with any numerical digit (0,1,2---9).
  • It should be formed using only letters, numbers or underscore.
  • In Identifiers, both uppercase and lowercase letters are distinct . Therefor , we can say that Identifiers are case sensitive.
  • Keywords can not be represented as an identifier.
  • The length of the identifiers will not more than 31 characters.
  • Identifiers should be written in such a way that is meaningful,short and easy to read.
  • It cant use white space

 

 

Post a Comment

0 Comments