Complete the code to declare a static variable inside a function.
void func() {
static int [1] = 0;
[1]++;
printf("%d\n", [1]);
}The variable count is declared as static inside the function, so it keeps its value between calls.
Complete the code to declare a static global variable.
[1] int counter = 0; void increment() { counter++; }
extern which declares an external variable.auto or register which are for local variables.Using static before a global variable limits its scope to the current file.
Fix the error in the code by completing the declaration of a static variable inside a function.
void demo() {
[1] int x = 5;
x++;
printf("%d\n", x);
}auto or register which are for automatic variables.extern which is for external linkage.The static keyword makes the variable x keep its value between function calls.
Fill both blanks to create a static variable inside a function and print its value.
void count_calls() {
[1] int calls = 0;
calls[2];
printf("Calls: %d\n", calls);
}The variable calls is static and incremented each time the function runs.
Fill all three blanks to declare a static variable, increment it, and print its value.
void func() {
[1] int num = 0;
num[2];
printf("Number: %d\n", [3]);
}The static variable num is incremented and printed each time func is called.