# static

Program 1:

```c
#include <stdio.h>
int a, b =0;
void prtFun (void);

int main (){
    static int a = 1; /* line 1 */
    
    prtFun();
    
    a++;
    
    prtFun();
    
    printf ("Inside main, a is %d and b is %d\n" , a, b);
}

void prtFun (void){
    static int a = 1; /* line 2 */
    int b = 10;
    a+=b;
    b++;
    printf ("Inside function, a is %d and b is %d\n" , a, b);

}
```

Output:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1712157271540/4fb6ef01-c9ab-46a9-bb14-920cce969f2a.png align="center")

Program 2:

```c
#include <stdio.h>
static int sum(int num1, int num2) {
    return num1 + num2;
}
int main() {
    int a = 5, b = 3;
    int result = sum(a, b);
    printf("Sum: %d\n", result);
    return 0;
}
```

Fact: **Access to static functions is restricted to the file where they are declared. Apart from that there is no difference between a normal and a static function in C.**
