The features of a variable defined to have an automatic storage class are as follows :
An automatic variable is declared by using keyword auto.
Syntax : auto type var-name;
Storage : Computer Memory
Scope : Local to the block in which variable is defined
Default Initial Value : Garbage Value
Lifetime : Till the control remains within the block in which variable is defined
Example:
#include<stdio.h>
int main()
{
auto int num=6;
{
printf(" %d",num);
}
printf("\n %d",num);
return 0;
}
Output:
6
6
Note: If no storage class is specified, by default it is auto.
An automatic variable is declared by using keyword auto.
Syntax : auto type var-name;
Storage : Computer Memory
Scope : Local to the block in which variable is defined
Default Initial Value : Garbage Value
Lifetime : Till the control remains within the block in which variable is defined
Example:
#include<stdio.h>
int main()
{
auto int num=6;
{
printf(" %d",num);
}
printf("\n %d",num);
return 0;
}
Output:
6
6
Note: If no storage class is specified, by default it is auto.
0 comments:
Post a Comment
Hey this is a test comment