Document 16
Document 16
A variable is a name of the memory location. It is used to store data. Its value can be
changed, and it can be reused many times.
A variable declaration is useful when you are using multiple files and you define your variable in
one of the files which will be available at the time of linking of the program.
Types of Variables in C
There are many types of variables in c:
1. local variable
2. global variable
3. static variable
4. automatic variable
5. external variable
When we declare a variable without initialising it, then it just stores some
garbage value or zero value. But if we assign some value to it, then it will be
overwritten with the new value.
way to represent memory location through symbols so that it can be easily identified.
type variable_list;
int var0=20; //global variable defined out of the main part of program
extern int var3=30; //external variable & also used as a global variable
//main() function that indicates the function should return an integer value.
static int var2=20; //static variable the value never will change
printf("local variable %d\n",var1);
return 0;
Output of program::--
local variable 10
global variable 20
static variable 20
external variable 30