A variable is an identifier that is used to represent a single data item i.e. a numeric quantity or a character constant. The data item must be assigned to the variable at some point of time in the program. This data item can then be accessed later in the program simply by referring to the variable name. Unlike constants that remain unchanged during the execution of a program, a variable may take different values at different times. 

All variables must be declared before they are used in the program. The general form of a declaration is shown as: - 
 
 
Data-type var_list;  
Data type must be a valid data type and var_list may consist of one or more identifier names with comma operators. The declaration tells the compiler what the variable names are and what type of data they hold.  Some declarations are: -  
 
int count;
short int num;  
double balance; 
float amount; 

The words int, short int, double and float are keywords and cannot be used as variable names. 

Assigning Values to Variables 
 
Values can be assigned to variables using the assignment operator (=): -
 var_name=expression;

An expression can be a single constant or a combination of variables, operators and constants. The statements: 
p1=3250.00;. (the expression is a single numeric constant) 
p2=4570.00;
p3= p1+p2;      (the expression is a sum of price1 and price2) 
are called assignment statements. Every statement must have a colon at the end. A statement implies that the value of the variable on the left of = is set to the value of the expression on the right. Therefore, 
  
count=count+1;
 
implies that the 'new value' of count (left side) has been set to the 'old value' of count plus 1 (right side).

The variables can be assigned a value at the time of the declaration itself. This is called initialization. The general format is: -
Data-type var_name=constant; 

Example: 
 
int value=250;
char name="Gaurav"; 
double amount=76.80;

Program to show declarations, assignments and initialization of various types of variables: -
 
# include <iostream.h>
void main(void)
 /*.......Declarations....... */
float a, b;
double c, d; 
unsigned u; 
/*.......Initialization....... */
x = 19283;
int l = 9182736;
/* ....... Assignments.......*/
a= 2345.987;
b= 1928.283647;
d= c =2.20;
u= 54637;
/* .......Displaying.......*/
cout<<"x ="<<x;
cout<<"l ="<<l;
cout<<"a ="<<a;
cout<<"d ="<<d;
cout<<"u ="<<"b ="<<"c =\n"<<u<<b<<c;

The output will be: 
: x = 19283  l = 9182736  a= 2345.987000  d= 1928.283647000000  u= 54637  b=2.200000 
 c = 2.200000000000