Syntax of variable declaration in C

Without variable, you can not imagine any programming language. Today, we will understand the syntax of variable declaration in C language.

C and C++ both have a similar syntax to declare a variable.

variable declaration in C

<data_type> var_name1, var_name2,var_name3...;
int a,b,c;
float salary,bankbalance;

Before assigning any variable, think about data type that you want to use to make a new variable. It totally depends on your usages or requirement.

Above you can see that I used int and float data types to declare a,b,c as an integer variable and salary, ‘bankbalance’ as a float variable respectively.

Keep in mind, we can only declare variables in C before processing any statement. Means you need to initialize variables on the top of the program like below syntax.


void main()
int  a,b,c;
float salary, bankbalance;


Hope that you understand variable declaration in C. Please ask your questions in below comment box.

You can also read

Leave a Comment

Show Buttons
Hide Buttons