Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

1.

Local variable:
A local variable in c is a variable that is declare in a function or
block of a code.
2. Global variable:
A variable that is declare outside the function or block of code. In the whole
program we can access the global variable anywhere in the program after it is
declared.
3. Static variable:
A Variable that is defined using the static keyword. It can be defined only once in
a program.
The default value is zero.
syntax: static datatype variable_name;
4. Automatic variable:
All the local variables are automatic variables by default. They are also known as
autovariables.
These variables lifetime is till end of the program
if we need we can use the auto keyword to define the auto variable.
syntax: auto data_type variable_name;
or
data_type variable_name;
5. External variable:
A variable can share between multiple c files. We can declare an external variable
using the extern keyword.
Their scope is global and the exist in b/w multiple c files
syntax: extern data_type variable_name;
ex: extern int x=25;

You might also like