
Storage Class II-241
void func(void);
static c=4;
void main()
{
clrscr();
while(c--)
{
fun();
}
}
OUTPUT:
i is 1 and count is 3
i is 2 and count is 2
i is 3 and count is 1
i is 4 and count is 0
b. Program with auto keyword
void func(void);
int c=4;
void main()
{
clrscr();
while(c--)
{
fun();
}
}
fun( void )
{
auto int i=0;
i++;
printf("i is %d and count is %d\n", i, c);
}
OUTPUT:
i is 1 and count is 3
i is 1 and count is 2
i is 1 and count is 1
i is 1 and count is 0
Explanation: Due to auto class, the value of variable does not retain between calling function; hence,
the value of i remains 1 throughout the different calling functions.
M11_ITL-ESL4791_02_SE_C11.indd 241 12/22/2012 ...