Variables are names used to identify some location of your computer\'s memory that can store data. They are called variables because the actual value that is held in this memory area can vary. Variables are of different types based on the size and type of data that it holds.
C has several variables types to handle data of different type and length. The following are the basic variable types in C:
|char||To store a single character|
|int||To store signed integer values|
|float||To store single precision floating point numbers|
|double||To store double precision floating point numbers|
A C program requires that you first inform the compiler about any variables that will be used in the program. This is called Variable Declaration. In a variable declaration you normally specify the variable type and variable name(s).
For example :
You declare an integer variable named count as:
You can declare multiple variables separated by comma as
int count, total, index;
int denotes the variable type and
count, total and
index are the variable names.
There are certain rules that need to be followed when naming the variables in C. They are:
As a good programming practise you should give meaningful names to the variables and avoid using uppercase letters. Remember C is a case-sensitive language so the variable names
count are not the same.