2. What is Token
C tokens are the basic buildings blocks in C language which are
constructed together to write a C program.
Each and every smallest individual units in a C program are
known as C tokens
3. Types of Token
In C Programming tokens are of six types.
They are,
I. Keywords (ex: int, while,float),
II. Identifiers (ex: sum, total),
III. Constants (ex: 10, 20),
IV. Strings (ex: “ram”, “hello”),
V. Special symbols (ex: (), {}),
VI. Operators (ex: +, /,-,*)
4. C TOKENS EXAMPLE PROGRAM
#include<stdio.h>
void main()
{
int x, y, sum;
x = 6, y = 6;
sum = x + y;
printf ("Total = %d n", sum);
}
main – identifier
{,}, (,) – delimiter
int – keyword
x, y, sum – identifier
main, {, }, (, ), int, x, y, sum –
tokens
output
Total = 12
Press any key to continue . . .
5. Conclusion
That means C program consists of various tokens and a token is either a keyword, an
identifier, a constant, a string literal, Special symbols or a operator. For example, the
following C statement consists of five tokens
printf(“welcome heren”);
The individual tokens are −
printf
(
“welcome heren”
)
;
6. Token Examples
No Token Type Example 1 Example 2
1 Keyword do while
2 Constants number sum
3 Identifier -66 69
4 String “Hello” “Prem”
5
Special
Symbol
(), {} @
6 Operators ++ /