C Variables

A variable is a name of the memory location. It is used to store data. Its value can be changed, and it can be reused many times.

Variable is a name given to a memory location where we can store different values of the same datatype during the program execution.

Every variable must be declared in the declaration section before it is used.

A variable name may contain letters, digits and underscore symbol. 

Rules for defining variables
  1. Variable name should not start with a digit.
  2. Keywords should not be used as variable names.
  3. A variable name should not contain any special symbols except underscore(_).
  4. A variable name can be of any length but compiler considers only the first 31 characters of the variable name.
Declaration of Variable
 
Declaration of a variable tells the compiler to allocate the required amount of memory with the specified variable name and allows only specified datatype values into that memory location.

 Declaration Syntax:

datatype variableName;

 Example
 
     int number;
     int a;    
     int _ab;
 
 The above declaration tells to the compiler that allocates each of 2 bytes of memory with the name number,a,_ab and allows only integer values into that memory location.
 
 
 
 

 



No comments:

Post a Comment