1. Variables defined local to a function disappear at the end of the function scope. So when we call the function again, storage for variables is created and values are reinitialized.
2. So if we want the value to be extent throughout the life of a program, we can define the local variable as “static.” Initialization is performed only at the first call and data is retained between func calls.
3. Static variables are local in scope to their module in which they are defined, but life is throughout the program. Say for a static variable inside a function cannot be called from outside the function but is alive and exists in memory.
1. Global Variables are also similar to the static variables but these variables are available outside the module/function and its scope is available through out the application.
2. These Variables can be accessed from any of the function