The Programming Gurus

C Tokens, Identifiers And Keywords


C Tokens, Identifiers And Keywords:
C tokens, Identifiers and Keywords are the basics in a C program. All are explained in this page with definition and simple example programs.

1. C tokens:
C tokens are the basic buildings blocks in C language which are constructed together to write a C program. Each and every smallest individual units in a C program are known as C tokens.
C tokens are of six types. They are,

  • Keywords (eg: int, while),
  • Identifiers (eg: main, total),
  • Constants (eg: 10, 20),
  • Strings (eg: “total”, “hello”),
  • Special symbols (eg: (), {}),
  • Operators (eg: +, /,-,*)

C tokens example program:
int main()
{
int x, y, total;
x = 10, y = 20;
total = x + y;
Printf ("Total = %d \n", total);
} 
where,
  • main – identifier
  • {,}, (,) – delimiter
  • int – keyword
  • x, y, total – identifier
  • main, {, }, (, ), int, x, y, total – tokens

2. Identifiers in C language:
  • Each program elements in a C program are given a name called identifiers.
  • Names given to identify Variables, functions and arrays are examples for identifiers. eg. x is a name given to integer variable in above program.
  • Rules for constructing identifier name in C:
  • First character should be an alphabet or underscore.
  • Succeeding characters might be digits or letter.
  • Punctuation and special characters aren’t allowed except underscore.
  • Identifiers should not be keywords.
3. Keywords in C language:
  • Keywords are pre-defined words in a C compiler.
  • Each keyword is meant to perform a specific function in a C program.
  • Since keywords are referred names for compiler, they can’t be used as variable name.

  • C language supports 32 keywords which are given below. Click on each keywords below for detail description and example programs.
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
0 Comments For "C Tokens, Identifiers And Keywords"

Back To Top