0

why is the output not similar if I type "int num_calls = 1;" instead of "static int num_calls=1;" ?

#include <stdio.h> void say_hello(); int main() { int i; for (i = 0; i < 5; i++) { say_hello(); } return 0; } void say_hello() { static int num_calls = 1; printf("Hello number %d\n", num_calls); num_calls++; }

12th Oct 2019, 2:28 PM
Sk. Ahmed Razha Khan
Sk. Ahmed Razha Khan - avatar
1 Answer
0
Because it is static variable when you use static infront of it .
19th Apr 2021, 5:15 PM
KUMAR SHANU
KUMAR SHANU - avatar