Variables in C
Variable is used to store the value. As name indicates its value can be changed or also it can be reused many times.
Syntax
Data type variable_name;
e.g.
int a;
Where ‘a’ is the variables.
Types of Variables in C:
There are many types of variables in c:
- local variable
- global variable
- static variable
- external variable
- Automatic variable
1. Local variable – A variable which is declared inside the function is known as local variable. It is used only inside the function in which it is declared.
2. Global variable – A variable which is declared outside the function is known as global variable. It can be used throughout the program.
3. Static variable – It is used to retain its value between multiple function calls. It is declared using static keyword.
4. External variable – You can share a variable in multiple C source files by using external variable. It is declared using extern keyword.
5. Automatic variable – Variable which is declared inside the block is known as automatic variable by default.
Watch this C Programming and Data Structure Video by Intellipaat:
Constants in C
Its value is fixed throughout the program that means constants are those variables which value is not changed throughout the program.
C constants can be divided into two major categories:
- Primary Constants
- Secondary Constants

There are two simple ways in C to define constants:
1. Using#define
e.g.
#include <stdio.h>
#define value 10
void main() {
int data;
data = value*value;
printf("value of data : %d",data);
}
Output
value of data : 100

2. Using const keyword
e.g.
#include <stdio.h>
void main() {
const int value = 10;
int data;
data =value*value;
printf("value of data : %d",value);
}
Output
value of data : 100
If you want to know more about C Data Types, refer to our C programs blog