* C tokens are the basic building blocks in C language which are constructed together to write a C program.
* These are the smallest, non-reducible, textual elements in a program.
* example:
int a ;
(this statement consist of 3 tokens)
* The compiler recognizes them for building up expressions and statements.
* A “C” language program is a collection of tokens, comments, and white spaces. C language includes the following five types of tokens.
In C language we have following tokens:
* Keywords
examples:
int, float, char, while
* Identifiers/ Variables
examples:
balance, calculate, salary, total, abc, xyz
* Literals / Constants
examples:
10, 23, 45.76, 345.65, “Hello”, “World”, ‘A’, ‘Z’
* Separators / Punctuators
example:
( ), { }, *, /, – , :
* Operators
example:
+, -, *, /, &&, ||, !
Example:
int main() { int a, b, sum; a = 10, b = 20; sum = a + b; printf ("Sum = %d \n", sum); }
where,
main – identifier
{,}, (,) – delimiter
int – keyword
a, b, sum – identifier
main, {, }, (, ), int, a, b, sum – tokens