Home » , » C - Variable Scope

C - Variable Scope

 C - Variable Scope

The existence of a variable in a region is called its scope, or the accessibility of a variable defines its scope. The scope of Variables is of utmost importance while accessing variables. We will discuss global and local variables below.

Local Variables

Whenever a variable is defined in a function or a block, it can be used only in that function or block. The value of that variable cannot be accessed from outside the function. Let us see an example wherein we will create and initialize local variables. We will also see how to access and use local variables:





Output



Global Variables
A variable has Global Scope, if it is defined outside a function i.e., the code body, and is accessible from anywhere. Let us see an example wherein we will learn how to create and work with global variables:

 



Output



If you liked the tutorial, spread the word and share the link and our website LANGUAGE CODING with others.

0 comments:

Post a Comment

Popular Posts

GENRES

 
Copyright ©

latest code update bloggingskillBest coding website in india

Created By Sora Templates | Distributed By Gooyaabi Templates