#include <stdio.h>
// Global variable
int global_count = 0;
// Function to increment a static variable
void increment_static() {
static int static_count = 0; // Static variable declared inside the function
static_count++;
printf("Static count incremented to: %d\n", static_count);
}
int main() {
// Increment global count multiple times
for (int i = 0; i < 3; i++) {
global_count++;
printf("Global count incremented to: %d\n", global_count);
}
// Call increment_static multiple times
for (int i = 0; i < 3; i++) {
increment_static();
}
return 0;
}
Global count: 0
Static count: 0