I have this C function with a static variable:
void plus_five() {
static int i = 10;
i += 10;
printf("%d", i);
}
int main() {
for(int i = 0;i < 10;i++) {
plus_five();
}
return 0;
}
I get this output: 10 20 30 40 50 60 70 80 90 100
Why does the variable get incremented even when it is set to 10 every time the function is executed?