a. Variable declaration

Primary Type Declaration

A variable can store any data type in C programming. The name of the variable has nothing to do with its type. The general syntax of declaring a variable primarily is

data_type var1,var2,...varn;

Here, var1var2,…varn are the names of valid variables.

Variables can also be defined in multiple lines instead of on the same line.

data_type var1;
data_type var2;
data_type varn;

When the variables are declared in single line, then the variables must be separated by commas.

Note: All declaration statements must end with a semi-colon(;).

For example:

int age;
float weight;
char gender;

In these examples, ageweight and gender are variables which are declared as integer data type, floating data type and character data type respectively.

Leave a Reply

Your email address will not be published. Required fields are marked *