Write a C program to demonstrate example of global and local scope. Here’s simple program to demonstrate example of global and local scope in C Programming Language.
Scope : :
“Scope” is just a technical term for the parts of your code that have access to a variable.
-
Variables defined outside a function are […] called global variables.
-
Variables defined within a function are local variables.
A local variable is a variable which is either a variable declared within the function or is an argument passed to a function.
A global variable (DEF) is a variable which is accessible in multiple scopes. It is important to note that global variables are only accessible after they have been declared.
Below is the source code for C program to demonstrate example of global and local scope which is successfully compiled and run on Windows System to produce desired output as shown below :
SOURCE CODE : :
OUTPUT : :
Above is the source code for C program to demonstrate example of global and local scope which is successfully compiled and run on Windows System.The Output of the program is shown above .
need an explanation for this answer? contact us directly to get an explanation for this answer