Constants And Variables


Variables are used to store data  in computer’s memory

  • To indicate the memory location, each variable should be given a unique name.
  • Variable names are just the symbolic representation of a memory location.
  • Rule of writing a variable is same as that of an identifier
  • Examples of variable name: x, add, student etc.


Constants are the tokens whose value can’t be changed during program.

  • Integer Constant :

    These the general numeric constants in program. These are of 3 types :
    1. Decimal constants (base 10) : Decimal digits are counting no. from 0 to 9. e.g. of decimal constants are 0, 322, 21, 43, 1 etc.
    2. Octal Constants (base 7) : Octal digits are from 0 to7. They must start with 0. e.g. of octal constants are 012, 021,0345, 023 etc..
    3. Hexadecimal Constants (base 16) : Hexadecimal digits are 0 to 9, A, B, C, D, E, F . They must start with 0x .e.g. of hexadecimal constants are 0x12, 0xAB, 0x12F etc..

  • Character Constant :

    They must be enclosed within single quotes.
    e.g. ‘a’, ‘A’, ‘213’ etc.

  • Escape Sequence :

    The characters which cannot be directly typed or have some special meaning in C can be displayed using Escape Sequence. In this the backslash ( \ ) causes “escape” from the normal way the characters are interpreted by the compiler.

  • String Constant :

    They must be enclosed in double quotes to specify them as String constant.
    e.g. “Myname”, “CAR” etc

Leave a Reply

Your email address will not be published. Required fields are marked *