Variables :-

A variable is a name of memory location. It is used to store data. Variables are changeable, we can change value of a variable during execution of a program. . It can be reused many times. 

Rules to write variable names: 

1. A variable name contains maximum of 30 characters/ Variable name must be upto 8 characters. 

2. A variable name includes alphabets and numbers, but it must start with an alphabet. 

3. It cannot accept any special characters, blank spaces except under score( _ ). 

4. It should not be a reserved word. 


Declaration of Variables : 

A variable can be used to store a value of any data type. The declaration of variables must be done before they are used in the program. The general format for declaring a variable. 

Syntax :

data_type variable,variable2, variable-n; 

Variables are separated by commas and declaration statement ends with a semicolon. 

Ex : int m,n,d; 

float x,z; 

char a,b; 


Assigning values to variables :

 values can be assigned to variables using the assignment operator (=). 

The general format statement is : 

Syntax : 

variable = constant;

 Ex : x=100; 

a= 12.25; 

m=‟f‟;