Programming Languages

PROGRAM TO DEMONSTRATE THE DIFFERENCE BETWEEN AUTOMATIC AND STATIC VARIABLES

/* PROGRAM TO DEMONSTRATE THE DIFFERENCE BETWEEN AUTOMATIC AND STATIC VARIABLES */

#include<stdio.h>
#include<conio.h>

void func1();
void func2();
void main()
{
textcolor(90);
clrscr();
printf(“\n\nFUNCTION CALLING ONE SHOWS CHANGES OF AUTO VARIABLE\n\n”);
printf(“\n\nAFTER FIRST CALL OF VALUE OF I IN AUTO VARIABLE IS \n”);
func1();
printf(“\n\nAFTER SECOND CALL OF VALUE OF I IN AUTO VARIABLE IS \n”);
func1();
printf(“\n\nFUNCTION CALLING SECOND SHOWS CHANGES OF STATIC VARIABLE\n\n”);
printf(“\n\nAFTER FIRST CALL OF VALUE OF I IN STATIC VARIABLE IS \n”);
func2();
printf(“\n\nAFTER SECOND CALL OF VALUE OF I IN STATIC VARIABLE IS \n\n”);
func2();
getch();
}
void func1()
{
auto int i=2;
printf(“i= %d\n\n”,i);
i+=2;
}
void func2()
{
static int i=2;
printf(“i= %d\n\n”,i);
i+=2;
}

ANIL VERMA
Hello Everyone, Welcome to A. V. Powertech.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.