What is a variable in C Language


What is a variable in C Language

A variable may be defined as a named memory location. The value of a variable can vary during the execution of a program.

Rules to name a variable in C Language

  1. Both digits and alphabets are allowed to name a variable.
  2. We can use both capital and small letters buy they are treated differently.
  3. First character must be an alphabet or underscore.
  4. Variable name can have digits after first character.
  5. Keyword are not allowed for variable name.
  6. We can’t use any special character other than underscore.
  7. Spaces can’t be given in variable name.

Examples of invalid variable names

1st First character can’t be a digit.
auto It is a keyword of C.
{triangle} Special characters other than underscore are not allowed.
student class Variable name can’t contain a space.
last-name Special character other than underscore are not allowed.

Variable Declaration 

The syntax for variable declaration is  <data-type> var-1,var-2,……….;


 int age ;

Above statement declares a variable named number of int type.


Initialization refers to assigning some value to a variable during declaration of variable.


long a=5;

Best Books of C

Lesson tags: C variables, declaration of C variable, rules to name a variable in c language, What is a variable
Back to: C Programming Language