Tokens in C Programming language

Tokens in C programming Language :

  • C Tokens are smallest Individual unit of a c program or Base Unit of C language. Tokens are Building blocks of C program.
  • A C program is Collection of C Tokens.
  • Few examples of tokens are keywords, operators, separators, constants, Identifiers, etc.
  • We can’t split the Token because token is smallest block of C program.

Let’s look at a example program to understand the C Tokens.

Example program to understand the Tokens in C Language :

Output :


Above program is basic Hello world program and It is executed without any errors and we got the result.

If we notice, There are lot of tokens invloved in the above program, Those tokens are

  • void keyword and one token.
  • The  main function is an Keyword/Identifier and  it also one token.
  • printf also a function, And it is also one token.
  • And Finally the return  and {..} all are tokens.

Note : We can’t split Tokens.

Example 2 : Spliting the Tokens :

Output :

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 : Spaces between the Tokens :

Output :

From above program it is clear we can have any number of spaces, tabs, etc. between two tokens. But we can not split a C token. because Token is the Smallest individual Element in C program.

You Might also like :

 

Venkatesh

Hi Guys, I am Venkatesh. I am a programmer and an Open Source enthusiast. I write about programming and technology on this blog.

You may also like...

Leave a Reply