Variable - C Tutorial


C variables are names used for storing a data value to locations in memory. The value stored in the c variables may be changed during program execution.

Declaration of Variable

Declaration of variable in c can be done using following syntax:

data_type variable_name;
data_type variable1, variable2,…,variablen;

where data_type is any valid c data type and variable_name is any valid identifier.

For example,

int a;
float variable;
float a, b;

Initialization of Variable

C variables declared can be initialized with the help of assignment operator ‘=’.

data_type variable_name=constant/literal/expression;


 int a=10;
 int a=b+c;

Multiple variables can be initialized in a single statement by single value, for example, a=b=c=d=e=10;

NOTE: C variables must be declared before they are used in the c program. Also, since c is a case sensitive programming language, therefore the c variables, abc, Abc and ABC are all different.