Variables

The variables represent the quantities which changes with the time. Each variable identified by a unique identifier in a program called variable name. The variables are used to store values which changes continuously. The length, breadth, area etc. are examples of variables which we have used earlier programs.
              The ANSI rules for variables names are as follows.
              1. Only uppercase and lowercase letters, digits and underscore can be used.
              2. Variable name always begins with letter.
              3. Only first 32 characters are significant.
              4. Keywords can not be used.
              5. Variables name are case sensitive. The Count and count are two different variables.
The care should be taken while choosing the names of variables, so that the names are appropriate to the quantities to be represented and meaningful. Consider the following variable names.
average
count
maximum
temp_calc
temp_fahr
The underscore character is used to separate the words in a variable name when name consists of multiple words. The digits are useful to have sequence of names with each name has same meaning, but digit differentiates the instances.

Variable Declarations

The variable are used to store the data values. Before storing a value into the variable, the variable must be declared. The format for the variable declaration is as follows.
Syntax:-
                        data_type v1,v2,...,...,vn;
Here data_type is one of the valid data type of the C. It is followed be the list of variables separated by commas. The v1,v2,..., vn are the name of variables. The ;(semicolon) shows the end of the declaration statement. The following are examples of valid declarations.
int max;
int sum,average;
float temp;
double pie;

Comments

Popular posts from this blog

Constants

Data Types in C Programming

Identifiers