Write a C program that illustrates the use local static variables and functions.

C Programming Language / Function in C Language

968

Program:

#include <stdio.h>

int main()
{
	void show(void);
	printf("\n First Call of show()");
	show(); 
	printf("\n Second Call of show()");
	show();
	printf("\n Third Call of show()");
	show(); 
	return 0;
}


void show(void)
{
	static int i; 
	printf("\n i=%d",i); 
	i++;
}

 

Output:

 First Call of show()
 i=0
 Second Call of show()
 i=1
 Third Call of show()
 i=2

Explanation:

None

This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.