Storage Classes Unit-4th
Storage Classes Unit-4th
7
with long it
auto
An
time Local variables By 4. 1
3. 2. There 3. 2. 1.
Charactristics STORAGE
on itsStorage
stays
matic storage default,
register
storage
class storage
externstatic function?
class auto exists.
It will
Wedatatype.
variables
of are tells Storage
can assume in
class
is auto defined (automatic) four
what existence.To
float
auto bi
(external)
storage
lled, float b; int main() This autoint main() class classstore
ariable of CLASSES If of
variable: are storage is a
a: storage we
is the also
variables
storage variable
auto given same within class
a;
(automatic
variable) storage storage do
is scope defines fully
classes
bles not storage is classes class not IN
as determines
created a auto. of either specify define
given function class class C
in a the depending
variable
are class C: life in
below a
until memory storage
variable,
eated of which
auto
the body i.e. a
: variable
howi.e. upon
by the class part
unction
and or mention we
default. are value the
in of the of
when called contents
in of CPU a
which variable program
ction variable storagethe
registers.
automatic many
long
of
it declaration,
variable. itin s can
is is is
definea available
nated class
access
and it
variables. time,
Ra of
to variah a varia
a.
auto variables :
Visibilityof
Automatic variables are visible only in a function in which they are declared.
o EXTERNAL VARIABLE
declared within function but external variables are declared
Automatic variables are
function. Hence it is called global variable. These variables are used by all the
outsidethe
function.
y;
extern int x,
extern float a:
variables which are declared outside main( ) are called external variables.
#include<stdio.h>
int a = 5;
main( )
void display{ ):
printf("\n Value of a in main( )= %d ".a );
display();
display()
3. STATIC VARIABLE
Static variables are defined within a function and they have the same scope rule of
automatic variables. But the value of static variables will be retained throughout the program.
static int a;
static int b = 5:
# include<stdio.h>
void main( )
int i;
for ((=1; i<=3; it+)
int a = 0;
printf("\n a =%d", a );
at+;
Output :
a = (
a = 0
a = 0 # include<stdio.h>
main( )
int i;
for ((=1; i<=3; it+)
static int a = 0;
printf("\n a =%d", a );
at+;
Output:
a = (0
a = 1
a = 2
register int a
for (a=1; a<=5, a++)
printf("n %d", a );
output :
1
2
3
4
5