Program to illustrate the concept of auto variable

Auto storage class


It is default Storage class which is used within a program or file.This variable
is defined and accessed within a function

 

#include<iostream.h>
#include<conio.h>
void main()
{
void fun();
int a=0;
cout<<a;
fun();
getch();
}
void fun()
{
int aa=10;     /*variable comes into existence*/
cout<<aa;
}

auto variable

In above example aa comes into existence at the start of function "fun" and dies at the end of the function.Auto is the default storage class means no storage specifier is used.