The extent of the variable depicts that the variable is accessible at a certain point in the program or not. The contrast between global variables and static variables lies in this idea as it were.
Global variables:
1) Global variables are put away in the Data Segment of the procedure.
2) Global variable’s life is until the life of the program and it very well may be gotten to by different files utilizing extern keyword.
3) The extent of the global variables stays all through the program likewise the life expectancy of these factors is all through the program.
Static variables:
1) A static variable can be proclaimed outside all functions or inside a function utilizing a static keyword before the data type of variable.
2) The extent of the static Variables stays inside the block of code in which they are made yet the life expectancy stays all through the program.
Along these lines, the fundamental distinction is between the scope of both types of variables.
Regards,
Nitesh Bavishiya