The scope and lifetime depends on the storage class of the variable in c language the variables, explain in detail with example program about Automatic variables

Automatic Variables 
     The variables which are declared inside a function are called atomatic variables. These are called automatic variables. These are called automatic because, their memory spaces are automatically allocated when the function is called the destroyed automatically when the function is exited.
Syntax:
auto datatype variable1, variable2,.... variable n;
where
auto - keyword to define automatic
Example:
void main()
{
auto int a,b;
auto float x,y;
}
Sample Program:
void main()
{
auto float p=5.5;
clrscr();
call2();
printf("\nP=%2.2f",p);
}
 void call1()
{
auto float p=10.54;
printf("\nP=%2.2f",p);
}
  call2()
 {
 auto float p=20.50;
 call1();
 printf("\nP=%2.2f",p);
 }

0 Comment "The scope and lifetime depends on the storage class of the variable in c language the variables, explain in detail with example program about Automatic variables "

Post a Comment