Tokens in C

A C program consists of various tokens and a token is either a keyword, an identifier, a constant, a string literal, or a symbol. For example, the following C statement consists of six tokens −



C Tokens Example

Printing Sum Of Two Numbers


Output Of Above Program


  • main – identifier
  • {,}, (,) – delimiter
  • int – keyword
  • x, y, total – identifier
  • main, {, }, (, ), int, x, y, total – tokens



A C identifier is a name used to identify a variable, function, or any other user-defined item. An identifier starts with a letter A to Z, a to z, or an underscore ‘_’ followed by zero or more letters, underscores, and digits (0 to 9).

C does not allow punctuation characters such as @, $, and % within identifiers. C is a case-sensitive programming language. Thus, Manpower and manpowerare two different identifiers in C.

Examples Of Identifiers

amount      count    total   move_name  a_123
myname50   _temp   j    average      retVal


Keyword is a predefined or reserved word in C library with a fixed meaning and used to perform an internal operation. C Language supports 32 keywords.

Every Keyword exists in lower case latter like auto, break, case, const, continue, int etc.


Character Set

In C language characters are grouped into the following catagories,

  1. Letters(all alphabets a to z & A to Z).
  2. Digits (all digits 0 to 9).
  3. Special characters, ( such as colon :, semicolon ;, period ., underscore _, ampersand & etc).
  4. White spaces.


A line containing only whitespace, possibly with a comment, is known as a blank line, and a C compiler totally ignores it.

Whitespace is the term used in C to describe blanks, tabs, newline characters and comments. Whitespace separates one part of a statement from another and enables the compiler to identify where one element in a statement, such as int, ends and the next element begins.

Examples Of Whitespaces

int age;

Therefore, in the above statement −

int age;

there must be at least one whitespace character (usually a space) between int and age for the compiler to be able to distinguish them. On the other hand, in the following statement −

fruit = apples + oranges; 

no whitespace characters are necessary between fruit and =, or between = and apples, although you are free to include some if you wish to increase readability.


In a C program, the semicolon is a statement terminator. That is, each individual statement must be ended with a semicolon. It indicates the end of one logical entity.

Given below is a statement −

printf("Hello, World!n");


Comments are like helping text in your C program and they are ignored by the compiler. They start with /* and terminate with the characters */ as shown below −

/* my first program in C */

You cannot have comments within comments and they do not occur within a string or character literals.

Example program for Comments