C Tokens

Token

Token means individual words and punctuation which are may not be meaning full word’s respect of English dictionary but there is a specific meaning of particular words in standard C compiler are called token. Each token have unique meaning in the C compiler and they have their different predefined job.

There are different types of tokens. They are classified as follows:






Keyword: Every word is used in C language which have its own meaning and own definition and which can’t be changed, that means keyword means when we use this key word in our programme  then we just use the meaning or the definition in our programme.
int
Float
char
long
Break
Case
Const
Continue
Default
Do
double
if
Else
Enum
extern
for
Goto
Register
return
short
Signed
Sizeof
static
struct
Switch
Typedef
union
unsigned
Void
Volatile
while
auto

There are some new keyword and add in the ‘C’ compiler they are _Bool, _Complex, _Imaginary, inline, restrict.

The upper table is showing there are the list of keyword’s and which have it’s own meaning like,

Int: this is a data type and only store integer type value and the size of int data type is 2 byte in case  of some new compiler provide 4 byte for integer variable.

Break:- break is a keyword which is used to terminate from a block.
So like the two key words they have their own meaning and different job.

Identifier:- identifier means the name of variable, function, array, structure which are given by the programmer to construct a programme or to give  instruction, called identifier. A variable name like int a,b; or function name like sum(); structure name like struct student, there are a,b,sum,student all are user defined and they are called identifier also.

# include <stdio.h>
# include <conio.h>
int main()
{
                int a,b;
                Sum();
                Return 0;
}
Here in the above programme, the integer data type a, b and the function name sum() is user define so the words  which are  block red letter present in the programme they are identifier, that means the word’s which is depend on the user choice those words are called identifier. There are some rules for choosing the identifier as follows.
Important rules for choosing the identifiers:-
Ø  First character of the identifiers must be an alphabet or underscore (always start with a-z or ‘_’).
Ø  Use only letters, digits, or underscore.
Ø  The first 31 character are significant.
Ø  The keyword can’t use as a identifier.
Ø  The blank space or the white space is not acceptable with in the identifier.


Constants
 

Constant:- constant means fixed value which is not going to be change during the execution. C language support several types of constant,




Constant: Mainly constants are of two types.

  • Numeric constans
  • Character constant
Numeric constant:- numerical constant means any numerical fixed value like2,5,2.0,2.5 etc. The numerical constant is two types,
Ø  Integer constant: - integer constant means collection of digits or the sequence of digits form a number, called integer constant.
There are some type of integer constant are decimal constant, octal constant and hexadecimal constant.
Example:- 2,4,-3
Code:-
#include <stdio.h>
Void main()
{
                Printf(“%d”,123);
}
Output:-
123
Decimal (6)10 , octal (5)8 , hexadecimal (A)16, briefly describe in the chapter of number system.

Ø  Real constant:- real number means the fractional number that means integer numbers with their fractional part, called real number or floating point number. The real number are  widely use to represent the continues quantities like distance, height, temperature.

Example: 2, 5.0, 3.5
Code:-
Void main()
{
                Printf(“%f”,2.5);
}
Output:-Code:-
Void main()
{
                Printf(“%f”,2.5);
}
Output:-
2.5
A real number may also be expressed in exponential notation, if there is a number 310.23 may be written as 3.1023e2 in exponential notation.e2 means multiply by 102 . the general form is, Mantissa e exponent

Single character constant:- A single character constant or character constant means contain a single character with in a pair of single quote.
Example:- ‘a’, ‘A’,’5’
Here ‘5’ and 5 are not same because ‘5’ character constant and 5 is numeric constant, if we want to do any operation between ‘5’ and 5, will no possible.

 String constant: - A string constant is a collection of characters with in double quotes. The character may be letters, numbers, special characters and blank space.
Example:- “Apple”,”mango”,”2+25*5”
Code:-
Void main()
{
                Prinf(“hello world”);
Printf(“254++8++asdfg”);
}

OUTPUT:

hello world254++8++asdfg

Note:- “hello world “ is just a string and the second line of the code is “254++8++asdfg” is also a string not a numeric expression. Remember that if a character constant ‘a’ and a string constant “a” looking both are same but a character constant and a string constant are different.


Backslash character constants:- Standard C language support some special character constant that are used in the output function like printf().


List of some characters:-
Backslash Character constant
Meaning or job

‘\a’
Audible alert(bell)
‘\b’
Backspace
‘\f’
Form feed
‘\n’
New line
‘\r’
Carriage return
‘\t’
Horizontal tab
‘\v’
Vertical tab
‘\”
Single quote
‘\”’
Double quote
‘\?’
Question mark
‘\\’
Backslash
‘\0’
Null




Translate