Variable is an identifier which holds data or another one variable. It is an identifier whose value can be changed at the execution time of program. It is used to identify input data in a program


Variable_name = value;

Rules To Declare a Variable

  • To Declare any variable in C language you need to follow rules and regulation of C Language, which is given below;
  • Every variable name should start with alphabets or underscore (_).
  • No spaces are allowed in variable declaration.
  • Except underscore (_) no other special symbol are allowed in the middle of the variable declaration (not allowed -> roll-no, allowed -> roll_no).
  • Maximum length of variable is 8 characters depend on compiler and operation system.
  • Every variable name always should exist in the left hand side of assignment operator (invalid -> 10=a; valid -> a=10;).
  • No keyword should access variable name (int for <- invalid because for is keyword).


In a c program variable name always can be used to identify the input or output data

Declaring And Initializing Variable

  • Variables should be declared in the C program before to use.

  • Memory space is not allocated for a variable while declaration. It happens only on variable definition.

  • Variable initialization means assigning a value to the variable.


There Are Three Types Of Variables

  1. Local variable

  2. Global variable

Example For Local Variable


Example For Global Variable