Explanatory Question
What is a static variable?
Read the answer carefully and go through the related questions on the right side to improve your understanding of this topic.
A static local variables retains its value between the function call and the default value is 0. The following function will print 1 2 3 if called thrice.
void f() {
static int i;
++i;
printf(“%d “,i);
}
If a global variable is static then its visibility is limited to the same source code.
First read the answer fully, then try to explain it in your own words. After that, open a few related questions and compare the concepts. This method helps you remember the topic for a longer time and improves exam preparation.