Advertisements

Search results for static

Example:[1]

            Write a program to demonstrate the use of static keyword in C programming.
          

            #include <stdio.h>
static int p;
int f(void) {
  static int x = 0;
  x++;
  return x;
}
int y(void) {
  int x = 0;
  x++;
  return x;
}
int main() 
{
  int j;
  printf("Static variable x:%d\n", p);
  for (j = 0; j < 5; j++) {
    printf("Value of f(): %d\n", f());
  }
  for (j = 0; j < 5; j++) {
    printf("Value of y(): %d\n", y());
  }
  return 0;
}
          

 Search Links


 Popular C search MCQs


 Popular C search examples