Home C Programming Language / Programs / Write a C program that illustrates the use local static variables and functions.
🚀 Programming Example

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

👁 1,067 Views
💻 Practical Program
📘 Step Learning
Write a C program that illustrates the use local static variables and functions.

💻 Program Code

#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++;
}

 
                        

🖥 Program Output


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

                            

📘 Explanation

None
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.