Tokens are the smallest individual unit of a program or in simple words it is a main part of C program.Tokens are the building blocks of any program. The smallest individual and basic unit of a C programming is called c tokens.
* Normally there are six types of tokens in C:-
i> Keywords:-
Keywords are special words that are used to give a special meaning to the program and can't be used as variable and constant.They are basically a sequence of characters that have fixed to mean. For example:-
auto double long break
float short char if
while continue int void etc.
All keywords must be written in lower case.It is 32 in number.
ii> Identifiers:-
The identifiers are basically a token. It can be a variable's name or a label's name. So identifiers are actually a user defined data. But there are certain rules to frame an identifier. They are as follows:-
* An identifier can have alphanumeric characters and underscore. i.e A-Z , a-z , 0-9 , _ .
* But it should always start with an alphabet or underscore.Not with a number.
* It should not be a reserved keyword.
* identifiers are actually case sensitive in C language. So flag and FLAG are actually different.
* Use of special characters is forbidden.
Also avoid starting an identifier with underscore because compiler thinks that it is system defined.
iii> Variables:-
The variables are used to give the name and allocate memory space. An entity that may vary during execution. Variables are the data item whose value may vary during the execution of the C program. A specific location or address in thre memory is associated for each variable and value of that variable is stored in that locatuion . All the variables must have their type indicated so that the compiler can recoard all the necessary information about them and generate the appropriate code during translation.
There are some rules to name a variable:-
* variable name must not start with a digit.
* Variable name can consist of alphabets, digits and special symbols like underscore.
* Blanks or spaces are not allowed in variable name.
* Keywords are not allowed as variable name.
* upper and lower case names are treated as different ,as C is case-sensitive, so it is suggested to keep the variable names in lower case.
iv> Constants:-
The quantity which does not change during the execution of a program is known as constant. It is use in assignment statements.Constants are stored in variables. There are five types of constant:-
* Character
* Integer
* Real (float)
* String
* Logical
A character constant is a constant which uses single quotation around characters. For example: 'a' , 'l' etc. An integer constant is a numeric constant without any fractional or exponential part.
A floating point constant is a numeric constant that has either a fractional form or an exponential form.
String constants are the constants which are enclosed in a pair of double-quote marks. For example: "good" , " ", "x" .
v> String:-
String is a collection of more than one character. For ex: "RAM" , " Meerut" . String is represented by a pair of double quotes. the length of a string is determined by a terminating null character('\0') . For using string the header file <string.h> is needed. The nine more commonly used functions in the string library are:-
* strcat-- concatenates two strings.
* strchr-- string scanning operation.
* strcmp-- compair two string.
* strcpy-- copy a string.
* strlen-- get string length.
* strncat-- concatenate one string with part of another.
* strncmp-- compare part of two strings.
* strncpy-- copy part of a string.
* strrchr--string scanning operation.
vi> Operators:-
Operators acts as connectors and they indicate what type of operation is being carried out. The values that can be operated by these operators are called operands. They are used to perform basis operations , comparision , manipulation of bits and so on. The operators include many types which are as follows:-
* Arithmetic operators.
* Logical operators.
* Relational operators.
* Assignment operators.
* Increment/ Decrement operators.
* Bitwise operators.
* Special operators.
* Normally there are six types of tokens in C:-
i> Keywords:-
Keywords are special words that are used to give a special meaning to the program and can't be used as variable and constant.They are basically a sequence of characters that have fixed to mean. For example:-
auto double long break
float short char if
while continue int void etc.
All keywords must be written in lower case.It is 32 in number.
ii> Identifiers:-
The identifiers are basically a token. It can be a variable's name or a label's name. So identifiers are actually a user defined data. But there are certain rules to frame an identifier. They are as follows:-
* An identifier can have alphanumeric characters and underscore. i.e A-Z , a-z , 0-9 , _ .
* But it should always start with an alphabet or underscore.Not with a number.
* It should not be a reserved keyword.
* identifiers are actually case sensitive in C language. So flag and FLAG are actually different.
* Use of special characters is forbidden.
Also avoid starting an identifier with underscore because compiler thinks that it is system defined.
iii> Variables:-
The variables are used to give the name and allocate memory space. An entity that may vary during execution. Variables are the data item whose value may vary during the execution of the C program. A specific location or address in thre memory is associated for each variable and value of that variable is stored in that locatuion . All the variables must have their type indicated so that the compiler can recoard all the necessary information about them and generate the appropriate code during translation.
There are some rules to name a variable:-
* variable name must not start with a digit.
* Variable name can consist of alphabets, digits and special symbols like underscore.
* Blanks or spaces are not allowed in variable name.
* Keywords are not allowed as variable name.
* upper and lower case names are treated as different ,as C is case-sensitive, so it is suggested to keep the variable names in lower case.
iv> Constants:-
The quantity which does not change during the execution of a program is known as constant. It is use in assignment statements.Constants are stored in variables. There are five types of constant:-
* Character
* Integer
* Real (float)
* String
* Logical
A character constant is a constant which uses single quotation around characters. For example: 'a' , 'l' etc. An integer constant is a numeric constant without any fractional or exponential part.
A floating point constant is a numeric constant that has either a fractional form or an exponential form.
String constants are the constants which are enclosed in a pair of double-quote marks. For example: "good" , " ", "x" .
v> String:-
String is a collection of more than one character. For ex: "RAM" , " Meerut" . String is represented by a pair of double quotes. the length of a string is determined by a terminating null character('\0') . For using string the header file <string.h> is needed. The nine more commonly used functions in the string library are:-
* strcat-- concatenates two strings.
* strchr-- string scanning operation.
* strcmp-- compair two string.
* strcpy-- copy a string.
* strlen-- get string length.
* strncat-- concatenate one string with part of another.
* strncmp-- compare part of two strings.
* strncpy-- copy part of a string.
* strrchr--string scanning operation.
vi> Operators:-
Operators acts as connectors and they indicate what type of operation is being carried out. The values that can be operated by these operators are called operands. They are used to perform basis operations , comparision , manipulation of bits and so on. The operators include many types which are as follows:-
* Arithmetic operators.
* Logical operators.
* Relational operators.
* Assignment operators.
* Increment/ Decrement operators.
* Bitwise operators.
* Special operators.
Comment for more important topics
ReplyDeleteGood nice topics
ReplyDeletethanks
Delete