Tokens: Tokens are the smallest independent, individual units of C language which are of more beneficial if they remain together rather than individual.
Types of tokens:
1. Identifiers.
2. Keywords.
3. Variables.
4. Constants.
5. Puntuator.
6. Operators.
Now explanation of above these points:
Identifiers-- any programs name or any variables name.
RULES FOR ASSIGNING THE NAME OF IDENTIFIER:
1. NAME SHOULD NOT START WITH SPECIAL CHARACTERS.
2. NAME SHOULD START WITH AN ALPHABET.
3. IN BETWEEN NAME WE CAN USE SPECIAL CHARACTERS, symbols etc.
4. GAPS SHOULD NOT BI GIVEN BETWEEN THE NAME.
5. INSTEAD OF GAPS WE CAN USE UNDERSCORE.
6. DOTS ARE NOT ALLOWED IN THE NAME.
7. HE NAME IS DIVIDED INTO TWO TWO PARTS I.E. MAIN NAME AND EXTENSION NAME. THE MAIN NAME HAS A MAX. WORD LIMIT OF 8 AND EXTENSION NAME HAS A MAX. OF 3 CHARACTERS.
2. Keywords-- are the special words , reserved words or words carring special meaning in C language.
For e.g. int , char, float, long, double, auto, for, while, do, break, switch, case, class etc.
NOTE-- SINCE WE CAN'T USE KEYWORDS AS IDENTIFIERS.
For e.g. we can't use " int" as an identifier because it is a keyword, but we can use it as "Int" because C language is a " case sensitive language" which we have already discussed in my previous blog.
3. Variables-- are those whose values can be changed at any time in the program, they store our value in them before processing , they hold memory for our values , they are the named memory chunks in which value is stored.
SYNTAX--
data type name. ;
Of variable
For e.g. int a;
They are of two types :
I. Global-- which has a tendency of changing its value throughout the whole program.
II. Local-- which has a tendency of changing its value throughout the void main only.
4. Constants or literals-- are those whose values cannot be changed during program execution.
They are of 4 types:
I) Character constant -- it include all the alphabet, characters, special symbols etc. which are written in single quotes facing toward left.
For e.g. 'a', '8', '$' etc.
II) Integer constant --it includes all the whole numbers which is a combination of numbers from 0 to 9.
III) Floating point constant-- it includes decimals or fractions.
For e.g. 9.0. , 4.8 etc.
IV) String constants-- it is a collection of characters written inside double quotes and terminated by null character('\0') and supported by data type "char" in C language.
For e.g. " sudhanshu@123"
5. Puntuators-- are the names which are given to special symbols in C language, a few of them are written bellow:
Special Common name in C
Symbol. Name. Language.
1. # hash. Pre processor
Directive.
2. {}. Curly delimiters.
Braces
3. (). Parenthesis. Symbol of function.
4. []. Square braces. Array size.
5. * Asterick. Pointer.
6. & Ampersand. Referencing.
7. : Colon. Label.
8. ; semi colon. Terminator.
6. Operators--
Two types of operators are :
1. Based on operands.
2. Based on operators.
A+ B
Here A and B are operands and + is operator.
1. Based on operands:
a. Uniary.
b. Binary.
c. Ternary.
2. Based on operators:
a. Airthmatic operators:
i.e. +, -, *, /.
Note: here the / gives us the qoutient.
b. Relational operators:
i.e. <,>,<=,>=.
c. logical operators:
These are used when we have more than one condition.
i.and gate(&&)
ii. Or gate(||)
iii. Not gate(!)
d. Equality operators:
i.e. LHS==RHS
e. Assignment operators:
i.e. LHS=RHS
f. Modulus operator:
ie. % it gives us remainder.
If you have any doubts please write it in the comments and I will try to solve it.
By sudhanshu tidyal
Types of tokens:
1. Identifiers.
2. Keywords.
3. Variables.
4. Constants.
5. Puntuator.
6. Operators.
Now explanation of above these points:
Identifiers-- any programs name or any variables name.
RULES FOR ASSIGNING THE NAME OF IDENTIFIER:
1. NAME SHOULD NOT START WITH SPECIAL CHARACTERS.
2. NAME SHOULD START WITH AN ALPHABET.
3. IN BETWEEN NAME WE CAN USE SPECIAL CHARACTERS, symbols etc.
4. GAPS SHOULD NOT BI GIVEN BETWEEN THE NAME.
5. INSTEAD OF GAPS WE CAN USE UNDERSCORE.
6. DOTS ARE NOT ALLOWED IN THE NAME.
7. HE NAME IS DIVIDED INTO TWO TWO PARTS I.E. MAIN NAME AND EXTENSION NAME. THE MAIN NAME HAS A MAX. WORD LIMIT OF 8 AND EXTENSION NAME HAS A MAX. OF 3 CHARACTERS.
2. Keywords-- are the special words , reserved words or words carring special meaning in C language.
For e.g. int , char, float, long, double, auto, for, while, do, break, switch, case, class etc.
NOTE-- SINCE WE CAN'T USE KEYWORDS AS IDENTIFIERS.
For e.g. we can't use " int" as an identifier because it is a keyword, but we can use it as "Int" because C language is a " case sensitive language" which we have already discussed in my previous blog.
3. Variables-- are those whose values can be changed at any time in the program, they store our value in them before processing , they hold memory for our values , they are the named memory chunks in which value is stored.
SYNTAX--
data type name. ;
Of variable
For e.g. int a;
They are of two types :
I. Global-- which has a tendency of changing its value throughout the whole program.
II. Local-- which has a tendency of changing its value throughout the void main only.
4. Constants or literals-- are those whose values cannot be changed during program execution.
They are of 4 types:
I) Character constant -- it include all the alphabet, characters, special symbols etc. which are written in single quotes facing toward left.
For e.g. 'a', '8', '$' etc.
II) Integer constant --it includes all the whole numbers which is a combination of numbers from 0 to 9.
III) Floating point constant-- it includes decimals or fractions.
For e.g. 9.0. , 4.8 etc.
IV) String constants-- it is a collection of characters written inside double quotes and terminated by null character('\0') and supported by data type "char" in C language.
For e.g. " sudhanshu@123"
5. Puntuators-- are the names which are given to special symbols in C language, a few of them are written bellow:
Special Common name in C
Symbol. Name. Language.
1. # hash. Pre processor
Directive.
2. {}. Curly delimiters.
Braces
3. (). Parenthesis. Symbol of function.
4. []. Square braces. Array size.
5. * Asterick. Pointer.
6. & Ampersand. Referencing.
7. : Colon. Label.
8. ; semi colon. Terminator.
6. Operators--
Two types of operators are :
1. Based on operands.
2. Based on operators.
A+ B
Here A and B are operands and + is operator.
1. Based on operands:
a. Uniary.
b. Binary.
c. Ternary.
2. Based on operators:
a. Airthmatic operators:
i.e. +, -, *, /.
Note: here the / gives us the qoutient.
b. Relational operators:
i.e. <,>,<=,>=.
c. logical operators:
These are used when we have more than one condition.
i.and gate(&&)
ii. Or gate(||)
iii. Not gate(!)
d. Equality operators:
i.e. LHS==RHS
e. Assignment operators:
i.e. LHS=RHS
f. Modulus operator:
ie. % it gives us remainder.
If you have any doubts please write it in the comments and I will try to solve it.
By sudhanshu tidyal
Comments
Post a Comment