GupShup Study
C - Tokens, Identifiers and Keywords
Neeraj Yadav

C - Tokens, Identifiers and Keywords

11-Jul-2016 | | Total View : 865 |


C tokens, Identifiers and Keywords are the basics in a C program.

C Tokens -

  • In a passage of text, individual words and punctuation marks are called tokens or lexical units. Similarly, the smallest individual unit in a c program is known as a token or a lexical unit.
  • C tokens are the basic buildings blocks in C language which are constructed together to write a C program.
  • C tokens are of six types-
  1. Keywords
  2. Identifiers
  3. Constants
  4. Strings
  5. Special Symbols
  6. Operators


C Keywords -

Keywords are predefined, reserved words used in programming that convey a special meaning to the c compiler. Keywords are part of the syntax and You cannot use it as a variable name, constant name etc.

The list of 32 C keywords is given below:

auto break case char const continue default do
double else enum extern float for goto if
int long register return short signed sizeof static
struct switch typedef union unsigned void volatile while

 Along with these keywords, C supports other numerous keywords depending upon the compiler.


C Identifiers -

Identifiers are the names you can give to entities such as variables, functions, structures etc. These are user defined names consisting of arbitrarily long sequence of letters and digits with either a letter or the underscore(_) as a first character.

Identifier names must be unique. They are created to give unique name to a C entity to identify it during the execution of a program. C does not allow punctuation characters such as @, $, and % within identifiers. C is a case-sensitive programming language. Thus, "Happy" and "happy" two different identifiers in C.

There are certain rules that should be followed while naming  c identifiers:

  • First character should be an alphabet or underscore (_).
  • They must consist of only letters, digits, or underscore. No other special character is allowed.
  • It should not be a keyword.
  • It must not contain white space.
  • It should be up to 31 characters long as only first 31 characters are significant.

 Some examples of c identifiers:

Name Remark
_A9 Valid
Temp.var Invalid as it contains special character other than the underscore
void Invalid as it is a keyword



Whitespace in C -

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.

int money;

there must be at least one whitespace character (space) between int and money for the compiler to be able to distinguish them. But, in the following statement −

a = b + c;

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

Hope you like this tutorial, Please share your thoughts by comment section below.

Please Share with your friends.



Share With Friends :  

No any Comment yet!