Mega Code Archive

 
Categories / C Tutorial / Language
 

Static variable

#include <stdio.h> int g = 10;   main(){     int i =0;      void f1();     f1();                 printf(" after first call \n");     f1();                 printf("after second call \n");     f1();                 printf("after third call \n"); } void f1() {     static int k=0;       int j = 10;                  printf("value of k %d j %d",k,j);     k=k+10; } value of k 0 j 10 after first call value of k 10 j 10after second call value of k 20 j 10after third call