STATIC STORAGE CLASS

static storage class is used to declare variable that retains their value even after the scope in which they define has ended.

Static variable are initialized only once and their value persist across multiple function call they have a local scope but global life time.

Storage -> memory

Default initial value -> zero

Scope -> local to the block in which variable is defined

Life -> value of the variable parsaised b/w different function calls

Ex

#include<stdio.h>

void increment();

int main(){

  increment();

  increment();

  increment();

  return 0;

}

void increment()

{

  static int i=1;

  printf(“%d”, i);

  i++;

}

Output:1 2 3