Token:
A token is a basic building block of language, which is used together to complete a program. This can also be defined as the smallest part of the program. As we saw in the sample program int, main etc..., all can be considered as tokens.
Tokens can be again classified to six types. They are:
1.Identifiers
2.Constants
3.Keywords
4.Symbols
5.Operators
6.Strings
We shall study in detail about all these in the below section.
1.Identifiers:
Identifiers are names given to functions,variables etc, and can be compared to those we use in Alzebra in Mathematics. But here identifiers have certain rules to be followed, they are:
a. The first character should be an alphabet or underscore.
b. The following characters can be alphabets or numbers or underscore.
c. They should not collide with the names of keywords.
d. As C programming is case sensitive the naming must be taken care.
e. Only the first 32 characters of the identifier are important, remaining are neglected.
f. There should not be any special characters in the name of identifier.
f. There should not be any special characters in the name of identifier.
Eg: int _g;-------->valid
char 95a;---->in valid (identifier cant start with number)
int void------>in valid (void is a keyword)
int 95'%--->invalid(special character not allowed)
2.Constants:
A constant is a quantity that doesn't change. This quantity can be stored in memory locations of the computer. Constants can be of two types:
a.Primary Constants -- integer constant, character constant, real constant etc....,
b.Secondary Constants -- array, pointers, structures, enum, union etc...,,
(Don't worry about the names we shall learn about them in coming tutorials)
3.Keywords:
A constant is a quantity that doesn't change. This quantity can be stored in memory locations of the computer. Constants can be of two types:
a.Primary Constants -- integer constant, character constant, real constant etc....,
b.Secondary Constants -- array, pointers, structures, enum, union etc...,,
(Don't worry about the names we shall learn about them in coming tutorials)
3.Keywords:
Keywords are predefined words in C. They are designated to do some work. Since it leads to ambiguity we cant use a keyword as identifier name.
Eg for Keywords: int , main, char , float etc....,
4. Symbols:
Symbols are the special characters, like *,$,%,^,&,(,),{,},etc......,
5.Operators:
Operators is a symbol that tells to perform a certain mathematical or logical operation on the operands. Operators can be unary,binary or terenary i.e, they need one, two and three operands respectively.
Eg:+,-,*,/,% etcc,,,,,.
C supports a wide variety of operators we shall learn about them in coming tutorials.
6.Strings:
String is a set of characters like a name, set of numbers etc...,
Eg: 1234,Rahul,dravid etc...,
Eg for Keywords: int , main, char , float etc....,
4. Symbols:
Symbols are the special characters, like *,$,%,^,&,(,),{,},etc......,
5.Operators:
Operators is a symbol that tells to perform a certain mathematical or logical operation on the operands. Operators can be unary,binary or terenary i.e, they need one, two and three operands respectively.
Eg:+,-,*,/,% etcc,,,,,.
C supports a wide variety of operators we shall learn about them in coming tutorials.
6.Strings:
String is a set of characters like a name, set of numbers etc...,
Eg: 1234,Rahul,dravid etc...,
Sign up here with your email
ConversionConversion EmoticonEmoticon