Write a C program to demonstrate example of global and local scope

By | November 3, 2016

Global and local scope


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 .

If you found any error or any queries related to the above program or any questions or reviews , you wanna to ask from us ,you may Contact Us through our contact Page or you can also comment below in the comment section.We will try our best to reach up to you in short interval.


Thanks for reading the post….

Leave a Reply