TOKENS IN C PROGRAMMING LANGUAGE
- Smallest individual unit of C Program is known as Token.
- There are Six types of tokens:
1. KEYWORD:
- In C Program a word which has fixed meaning is called keyword.
- During program its meaning is not changed.
- All keyword are in lower-case.
- There are 32 keywords:

2. IDENTIFIER:
- Identifier is a name of variables and user defined function.
Rules of Identifier:
- It can be in lower case or upper case. Ex. int total; , int TOTAL;.
- It includes alphabets, numbers, underscore. Ex. int no1;.
- It doesn't start with number/digit. Ex. int 1no;--(wrong) , int _no;--(right).
- It doesn't contain white space. Ex. int stu no;--(wrong) , int stu_no;--(right).
- It can't use a keyword. Ex. int void;--(wrong).
- We can give 31 letters.
3.CONSTANTS:
Constant:
- Constant is a fixed value which can't be changed during the execution of program.
- There are three types of constants:
- Numeric Constants
- Character Constants
- Backslash Character Constants
1.NUMERIC CONSTANT:
Numeric Constant has two part:
A. Integer:
- Integer numbers contain numbers from 0 to 9.
- It doesn't contains numbers with fractional part (Floating Point).
- Decimal Numbers:
- Decimal numbers contains number from 0-9, +&- sign can be given at prefix position (Starting).
- We can't use special symbols.
- Example:
- Octal:
- It contains digit from 0-7.
- It starts with 0.
- Examples:
- Hexa Decimal:
- Hexa Decimal contains digit from 0-9 and characters from A-F.
- It starts with ox.
- Example:
B. Real:
- Real Constants contains digit from 0-9 with fractional part (Floating Point).
- -&+ sign can be allow at prefix position.
- Example:
2.CHARACTER CONSTANT:
- Character Constant can be single character or string character.
- Single Character Constant:
- Single Character Constant contains single character. It is represented by single quote.
- Example:
- String Character Constant:
- String is a set of character.
- C Language does not support string data type.
- To declare string, we can use character array.
- Example:
3.BACKSLASH CHARACTER CONSTANT:
- Backslash character constant are used in output function for display purpose.
- It is a specified by \ and single character.
4. STRING:
- String is a set of character.
- C Language does not support string data type.
- To declare string, we can use character array.
- Example:
5. SPECIAL SYMBOLS:
- Special Symbols are use to follow syntax of C program. If we don't follow this syntax then error will be occurred.
- Example:
6. Operators:
- Operators are use to perform any operations on different operands.
- Operands can be values or variable.
- C support 8 operators like Arithmetic operator, Relational operator, Logical operator etc...
- Example:
- + , - , * , / , % , == , = , >= , <= are examples of operators.
Comments
Post a Comment