Tokens:-
Tokens are the smallest unit,which are used to create a program in any programming language.
There are some tokens in C:-
- Character set
- Constant
- Variable
- Operator
- Data type
- Keywords
- Escape sequence
- Format specifier/type specifier
- Identifier
- Comment
- Delimeter
- Expressions
➤ Character set:-
It represents different types of character, that are categorized into three parts.
- Alphabet (A-Z) or ( a-z)
- Digit (0-9)
- Special character (@,$,%, etc)
➤Constant:-
- It is a fixed value which cannot be changed during execution of program.
- It is also known as literal.
It can be divided into three parts :
types of Constant |
⏩ Character Constant :
It represents only single character that must be enclosed within single cot.
eg:- 'A' , '6' , 'm' , '$' , etc.
⏩ String Constant :
- It is a group of zero, one or more characters which are enclosed within double cot.
- It must be terminated with null character (\0).
- Null character represents ending of character in string.
"1" ⇒ 1 \0 (written inside it ⃣⃣)
⤔here "\0" denotes end of the character
➤ Variables :-
Variables is a storage/memory location which is used to store constant value according to requirement.
The value of variable can be changed during execution of program.
eg:-
a = 10
b = 10.5
name = "xyz"
ch = 'A'
➳here:- a,b,name and ch are variables.
There are two types of variable:-
- Local Variable
- Global Variable
⏩ Local Variable:-
- This type of variable must be declared within any particular function.
- It provides local accessibility.
- It means , these variable can not be accessed outside function.
⏩ Global Variable:-
- These variables must be declared outside function.
- It can be accessed outside function.
- We can say that it provides global accessibility.
No comments:
Post a Comment