Hi Guest 1 HomePage 1 Jobs 1 WalkIn 1Articles  

 :) Latest Topic
Introduction to C
History of C Language
C Variables
Variables Types in C
C Identifiers
C Operators
C Comments
ASCII Value C
Constants C
Features of C
Install C Language
Start C Program
Compilation in c
printf() and scanf()
C Data Types
C Keyword
Format Specifier C
Format Specifier part2
Escape Sequence C
Tokens in C
Boolean in C
What are literals?
 


  

 
Tokens in C
Question Posted on 22 Oct 2023

Home >> Tutorial >> C Language >> Tokens in C


Tokens in C
When we say about the Token in C, it is most important element which is used to create a program in C. And here token is used as the smallest individual element in C. To understand this we will take and example, as we can not create sentence without the words, similarly you cannot create a program in C without using tokens in C. We can also say that C is the building block or the basic componenet for creating a program in C language.

Classificatin of Token

Token in C lanague is divided in below 6 category:-



(1)Keywords in C
(2)Identifiers in C
(3)Strings in C
(4)Operators in C
(5)Contant in C
(6)Special Characters in C

Now understand each token one by one.

(1)Keywords in C
When we say about the keywords, it can be defined as the pre-defined or we can say reserve words. Each of these keywords has there own importance and its own functionality. As these are pre-defined words compiler will not allow us to use that keyword as the variable names. And if you are trying to use these keyword as variable name, which means you are assigning a different meaning to the keyword, which is not allowed. C language mainly support below 32 keywords as given below:-



(2)Identifiers in C
When we say about the identifiers in C these are used for naming variables, arrays, functions, structures etc. And indentifiers in C are the user-defined words. And these identifiers are composed of lowercase letters, uderscore, uppercase letters or digits. But the starting letter should be either an underscore or an alphabet. We cannot use identifiers as keywords. Below are the different rules for constructing identifiers in C:-
(1)First character of an identifier should be either an alphabet or an underscore and then it is followed by any of the character, digit or underscore.
(2)We cannot use numerical digit as first character or we cannot we cannot start this from alphanumeric.
(3)We cannot use commas or blank spaces within an identifiers.
(4)We cannot use keywords as an identifier.
(5)There is limit on identifiers and should not be more than 31 characters.
(6)When we ask about identifiers both uppercase and lowercase are distinct. So we can say that identfiers are case sensitive.
(7)We must write identifiers in such way that it is meaningful , short and easy to read and view.


(3)Strings in C
When we talk about the strings in C, these are always define as represented as an array of characters having null character "\0" at end of the string. And this null character denotes the end of string. Strings are in C enclosed within double quotes. And characters are enclosed in single characters. And the size of string is a number of characters which string contains.

Now we describe the strings in different ways.

char a[18] = "crackyourinterview" //Here compile allocates 10 bytes to the 'a' array.

char a[] = "crackyourinterview" //here memory will allocate at runtime

char a[18] = {'c','r','a','c','k','y','o','u','r','i','n','t','e','r','v','i','e','w','\0'}; //here string is represented in form of characters


(4)Operators in C
When we say about the operator in C, its a special symbol which is used to perform the functions. And the data items on which operators are applied are known as oeprands. Operators are applied between the operands. Depending on the number of operands, operators are classified as given belows-
(i)Unary Operator:-When we say about the Unary operator this is applied on a single operand. Just like increment operator is (++), decrement operator is (--), sizeOf, (type)*.
(ii)Binary Operator:-Binary operator is an operator applied between two operands. Below are the list of binary operators:-
Arithmetic Operators
Relational Operators
Shift Operators
Logical Operators
Bitwise Operators
Conditional Operators
Assignment Operator
Misc Operator

(5)Constants in C
Contants is a value assigned to the variable which remain same throughout the program. And constant value can not be changed.
Below are the two ways of declaring constant
(i)Using const keyword
(ii)using #define pre-processor


Types of Contants in C


Special characters in C
Some special characters are used in C and they have a special meaning which cannot be used for another purpose.
(i)Square brackets[]:-Here opening and closing brackets represent the single and multidimensional subscripts.
(ii)Simple brackets ():-This is mainly used for function declaration and function calling. Like printf() is a pre-defined function.
(iii)Curly braces { }:-We use this for opening and closing of code. And we can also used in opening and closing of loops.
(iv)Comma (,):-We used this for separating for more than on statement and to understand this we will take an example of parameters in function separated by ",". Separating the variable when printing the value of more than one variable using a single printf statement.
(v)Hash/pre-processor (#):-This is mainly used for pre-processor directive and this is basically denotes that we are using the header file.
(vi)Asterisk (*):-We use this asterisk to represent pointers and also used as an operator for multiplication.
(vii)Tilde (~):-We used this to destruct and free the memory.
(viii)Period (.):-We used this to access member of a structure or a union.





Other Important Questions
Features of C
Introduction to C
History of C Language
Install C Language
C Variables







 
Top Searches:asp net questions vb net questions sql query uddl questions class javascript Questions sharepoint interview questions and concept silverlight questions and concept wcf questions beans general knowledge ajax questions
PHP | Biztalk | Testing | SAP | HR |