Tokens in C language | What are the C Tokens ??
Tokens in C programming Language :
- C Tokens are smallest Individual unit of a c program. Tokens are Building blocks of C program.
- A C program is Collection of C Tokens.
- Token can be keyword,operator,separator,constant,Identifier..etc..
- We can’t split the Token because token is smallest block of C program. here is a example to understand the C Tokens.
Example Program 1 : To Understand the C Tokens :
1 2 3 4 5 6 |
#include<stdio.h> void main() { printf("Welcome to Sillycodes n"); return; } |
Welcome to Sillycodes.
We know that any program will execute without any errors. in the above program we have many tokens,
those are
- void is keyword and one token.
- main is Identifier and it also one token.
- printf is function it is also one token.
- return, {, }… all are tokens. A C Program is Collection of Tokens.
Note : We can’t split Tokens.
Example 2 : To Understand C Tokens :
1 2 3 4 5 |
vo id ma in () { pri ntf("Welcome to Sillycodes n"); ret urn; } |
Error.
If you see above program, I try to divide the token. but i got compilation errors.. Because Token is the smallest Individual element in C program. we can’t divide it.
Note : We can’t split C tokens but we can have any number of spaces and tabs and newlines between two tokens.
Example 3 : To Understand the Tokens in C programming :
1 2 3 4 5 6 7 8 |
void main () { printf ("Welcome to Sillycodes "); } |
Welcome to Sillycodes
From above program it is clear we can have any number of spaces, tabs.. between two tokens. but we can not split a C token. because C Token is the Smallest individual Element in C program.
You Might also like :
- Compilation Phases of C program.
- Structure of C program Explained in Detail.
- Arithmetic Operators with Examples.
- Arithmetic operators priority and it’s Associativity.
- Modulus Operator and Hidden Concepts of Modulus Operator.
- Precedence Table or Operators Priority Table.
- Assignment Operator, Usage, Examples
- Increment Operator and Different types of Increment operators Usage with Examples.
- Decrement Operator and Different types of Decrement operators with Examples.
- Logical Operators tutorial with Examples.
- Relational Operators Tutorial with Examples.
- Conditional Operator tutorial and In depth analysis.
- Comma Operator Tutorial.