Variables in C Programming

  • A variable can be defined as a memory location declared to store any kind of data (which may change many times during program execution).
  • It can also be defined as any quantity/entity which may vary during program execution.
  • Variables are the identifiers of a memory location.
  • To identify a variable (the declared memory location), it can be assigned a name – known as a variable name.
  • The name given to a variable is known as an identifier.
  • An identifier can be a combination of alphabets, digits, and underscore.


           datatype Variablename;


  1. int mark;
  2. float a,b,result;

Variable naming rules

  1. It should be unique but not a keyword.
  2. The first letter should be an alphabet.
  3. White space, symbols, special characters are not allowed.
  4. Underscore can use ( _ ).
  5. Uppercase and lowercase letters are evaluated differently.

Variable initialization


           datatype variablename = size;


  1. int sum=10;
  2. int result=0, mark, sub=10;
  3. const float pi=3.14;
  • In the first example the variable 'sum' is assigned with a value 10,which is called variable initialization.
  • In the second example, the variable 'result' is assigned with a value 0, the variable 'sub' with a value 10.but the variable 'mark' indicates a normal variable declaration. In the third example, the variable pi declares as a constant with value 3.14, which cannot be altered during the program run.