C Programming

Variables in C

variable is a name of memory location that is used to store the data. We can change its value and reuse it.

 Example. int a;  // a is the variable of type int.
                 flaot b; // b is the variable of type float.

Rules to Declare  Variable

  1. Variable may be combination of digit(0-9), alphabet(a-z, A-Z) and under score(_).
  2. Variable name does not contain any blank space.
  3. Does not start with digit.
  4. Does not contain any reserve keyword.
Example:

    int abc;          // Right
    int a2bc;        // Right
    int 2abc;        // Wrong,   Does not start with digit
    int _abc;        // Right
    int a bc;         // Wrong,  Does not contain blank/white space
    int float;        //Wrong,    Variable name must not be reserve keyword

Types of Variable in C

There are many types of variables in c:
  1. local variable
  2. global variable
  3. static variable
  4. automatic variable
  5. external variable