C Tokens

C Tokens : Token is nothing but a part of instruction written in a program. For example if program has instruction like 
int a = 5;
Then compiler will break this instruction into various parts as int, a, =, 5 all these are called tokens.

There are different types of tokens in C language as follow :



1) Keyword : Every language has it's own predefined set of words reserved for it's own purpose such a words are called as Keywords. Users can not use them for creating user defined members in a program. C language has 32 Keyword they are as follow



2) Identifiers : The names given by user to members of program (like variables, constants, functions etc.) while writing program are called identifiers. C language specifies some rules for defining identifiers as - they should start with letter or _ (underscore symbol) only, they can contain alphabet as well as numbers but no special symbols except $ and _ are allowed.

3) String : A sequence of characters including alphabets, numbers, special symbols is called string. Strings are enclosed in " " (double quotes) always. C language makes use of character array to  store string values in memory.

4) Constants : Constants can be declared using const keyword using appropriate syntax in C. Values of constants is fixed throughout the program. 

5) Operators : Operator is a symbol used to perform operation on operand. C supports unary, binary as well as ternary operator. Unary operators in C are ++(increment), --(decrement), &(address of) etc. Binary operators include arithmetic operators (+, -, *, /, ^, %) and logical operators (&& (and), ||(or), !(not)). Conditonal operator(? :) in C is a ternary operator.

6) Special Symbols: C also supports some special symbols or characters as token. 

Comments

Popular posts from this blog

Write a program to allocate memory dynamically for n integers. Accept the elements and calculate their sum and average

C program to accept names of n cities and search for city named “Pune”.