What is Variable and its Scope in C Programming | Allinonetuts

What is Variable and its Scope in C Programming

Variable :

A variable is a name given to some known or unknown quantity. It is a means of symbolically representing a data storage location and its content, a quantity which could change numerous times during the course program execution.

Scope of Variable:

The scope of a variable describes where in a program’s text, the variable may be used, while the extent (or lifetime) describes when in a program’s execution a variable has a (meaningful) value. The scope of a variable is actually a property of the name of the variable and the extent is a property of the variable itself.

The scope of a variable can be defined as an area in a segment of program statement in which that variable is particularly used.

For Example:

#include <stdio.h>
#include <conio.h>
int global = 20;
int local = 20;
printf(“\n Local = %d”, local);
local = local + 10;
printf(“\n Global = %d”, global);
printf(“\n Local = %d”, local); 
global = global + 10; 
printf(“\n Global = %d”, global); 
printff“\n Bank to Main”); 
printf(“\n Local = %d”, local); 
printf(“\n Global = %d”, global); 
int local = 50;
printf(“This is a function”); 
printff“\n Local = %d”, local); 
local = local + 10; 
global = global + 10; 
printf(“\n Local = %d”, local); 
printff“\n Global = %d”, global);


local = 20 
global = 20 
local = 30 
global = 30 
This is a function 
local = 50 
global = 50 
local = 60 
global = 40 
Back to Main! 
local = 30 global = 40

This program clearly shows the scope of variables.

Click here: for more tutorials of c programming

Hope you like this articles! if you really like this article so don’t forget to give us a small feedback or review

Hello Viewers,
welcome to the Allinonetuts a Technical tutorial and Programming Blog Maintained by Vikas Kardam, a Web Developer and Blogger From Delhi, India.
What is a Variable and its Scope in C Programming was last modified: July 1st, 2017 by Vikas Kardam
Submit your review

Create your own review

Average rating:  
 1 reviews

Great article for my note making

Leave a Reply

Your email address will not be published. Required fields are marked *