Tokens in C

Prince Patel
By -
0

Tokens in C 

A C program consists of various tokens and a token is either a keyword, an identifier, a constant, a string literal, or a symbol. C tokens are the basic buildings blocks in C language which are constructed together to write a C program. 
In short, C tokens means each and every small part of a program is known as a C Tokens. 

There are mainly five type of token in C: 
  1. Identifiers. 
  2. Keywords. 
  3. Strings. 
  4. Constants. 
  5. Operators. 
  6. Special Character. 

Identifiers: 

Each program elements in a C program are given a name called identifiers. Names given to identify Variables, functions and arrays are examples for identifiers. 

RULES FOR CONSTRUCTING IDENTIFIER NAME IN C: 
  • First character should be an alphabet or underscore. Succeeding characters might be digits or letter. 
  • Punctuation and special characters aren’t allowed except underscore. 
  • Identifiers should not be keywords. 
  • Identifiers can’t accept white space.

Keywords: 

Keywords are pre-defined words in a C compiler. 
Each keyword is meant to perform a specific function in a C program. Since keywords are referred names for compiler, they can’t be used as variable name. 

C language supports 32 keywords which are given below.

Strings: 

The String is a seat of a character. The String is used to print any data. The String is must be Written between double inverted comma (“String”). 

Constants: 

C Constants are also like normal variables. But, only difference is, their values can not be modified by the program once they are defined. 
Constants refer to fixed values. They are also called as literals Constants may be belonging to any of the data type. 
Syntax: 
const data_type variable_name; 
(or) 
const data_type *variable_name; 

Special Character: 

There are some characters which have special meaning in C language. They should be preceded by backslash symbol to make use of special function of them. 
List of special characters and their purpose:

Post a Comment

0Comments

Post a Comment (0)