Keywords and Identifiers


Tokens


Tokens are the smallest individual unit of program. C has following six type of tokens.


  • Keywords
  • Identifiers
  • Constants
  • Operators
  • Special symbol
  • Strings

For example, the following C statement consists of six tokens:

scanf(ā€œ%dā€,&a);

  • scanf
  • ()
  • ""
  • %d
  • ,
  • &a

Identifiers


Identifier are the name used to identify a variables, functions and user-defined names. It consisits of both uppercase and lowercase characters ,underscore ( _ ) and digits.


Rules of Identifiers

  • An identifier starts with a letter A to Z, a to z, _ followed by zero or more letters, underscore and digits.
  • Must not contain special characters such as @, $, and % and white space.
  • Keyword cannot be used as a identifier.

Keywords


Keywords are the reserved words with specific meaning. The keywords cannot be used as constants or variable or any other identifier. C has following keywords.

Keywords in C - TechEureka

Constants


Constants are fixed value that do not change during execution of program. Constants are of following types :

  • Integer Constants
  • Real Constants
  • Single Character Constants
  • String Constants


Variables

Variable is the name of storage location that program can manipulate. Each variable has specific type which determines the size occupied by variable in memory.


Declaration of Variables

Declaration specify two things :

  1. It tells the name of variable to compiler.
  2. It tells the type of data that variable will store.

Syntax:

data-type var1, var2;

Where v1, v2 are variable name.

Example:
int n,s,a;
double ratio;
int ,double are keyword representing the data type. And n, s, a, ratio are variable names.



Key points


Do You Know?