Static variables with block scope.

static variables with file scope.

extern int var





C also provides facility to declare static variables. As the name indicates, the static variables retain its value as long as the program execute. You can declare a static variable by using thestorage class access specifier. For example,Static variables can be of two types depending on the placement of the declaration.Static variables with block scope are those which are declared inside a function. The scope of these type of static variables are same as that of auto variables i.e. they are accessible only within the function they are declared and cannot be accessed from outside. However, unlike auto variables they are not created and destroyed each time the function in which they are declared is called, rather they are created once and they retain their value throughout the life of the program. So the last value stored in the variable when the function is exited is available to the function, next time it is called . Also static variables can be initialized with constants or constant expression. If not initialized , bu default they are initialized to 0. Static variables are frequently used in situation in which ypu want to retain information between function calls such as number of times the function is called etc.OUTPUT:Registers are special storage areas within a computer's CPU. The actual arithmetic and logic operations that comprise a program are carried out within these registers. Normally, these operations are carried out by transferring information from the computer's memory to these registers, carrying out the indicated operations and then transferring the results back to the computer's memory. This procedure is repeated many times during the course of program's execution.C also permits to declare a variable using astorage class specifier. When register specifier is applied to a variable then the value of the variable is stored in the CPU register rather than in memory where normal variables are stored.You can declare register variable within a block by prefixing its declarationstorage class specifier. For instance,Declaresto be a register variable of typeOne should remember that as register variables are not stored in memory so it is illegal to use the address operator to determine the address of the register variable.OUTPUT:The global variables can be accessed by all the functions that follows its definition in a source file. These variables can be used to share information in a program that expands across multiple files. If a global variable is defined in some file and you want to use this extern variable (which stands for external) using the keywordas follows.Now let us consider the following program consisting of two files that show how to usestorage class. Thecontains a function that increment a variablebywhen called . The other filecontains the code as shown below.The code of theis follows,The code of theis as follows,We compile these two program files separately and remove errors if any. As they are part of same program so it is necessary to link them to create a single executable file.