Concept of Local and Global Variables In C, two types of variables are used:
(a) Local variables
(b) Global variables
Local variables are the variables whose scope is limited within the block in which they are defined or the function in which they are defined. They are always defined at the top of the block.
When a local variable is defined, it is not initialized by the system; in fact, you must initialize it as a
programmer. When the execution of a block or a function starts the variable is available and when the
block ends the variable dies.
For example,
int x= 40;
main( )
{
int x = 20;
printf(“\n%d”, x);
}
The output of this program will be 20. Why? As we can see in the first line, we have initialized x
to 40. This is known as a