answersLogoWhite

0


Best Answer

Scope refers to the accessibility of an object. A globally scoped object is available globally (to the entire program) while a locally scoped object is only available locally (to the containing function or class). In general, you want to avoid global objects whenever possible as it tends to introduce dependencies.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

If you have global memory it is defined outside of your scope and you can access it in all of your scopes.

If you have local memory it is defined within a scope and can ONLY be accessed in that particular scope.

If you have a global and a local variable with the same name the local will be selected.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the difference between a global scope and a local scope?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is the difference between local and global variable of C language?

4m Sai. Gloabal Variable is variable which is declared before main (). int a=10; main() { } here a is a global variable. where ever u r using this variable ... we'll get the value as 10. Local Variable is a variable which is declared inside the main(). int a=10; main() { int a=5; ........ ....... } here a=5 is a local variable and a=10 is called as global variable. then if u want to get a value... printf("%d",a); then result 'll be a=5; B'cos compiler gives main preference to local variables.. if any local declareation is not there then it 'll prefer global variable.


Difference between global and local variables?

The scope or the life span. The life span is from the birth (allocation) to death (deallocation). The life span of a global variable starts when the application is invoked. It dies when the application terminated. During the execution of the application , this global variable is available to any program unit within that application. The life span of a local variable, well, only locally. "Local" means a component, a method (subroutine), or even within a bracket ({} or BEGIN-END) of a statement. Outside of that block of codes, that local variable does not exist, hence cannot be accessed or referenced. Also, the same name of that local variable may be declared again in another local area without conflict, nor memory of the previous one. For languages similar to C: for (int i = 0; i < 100; i++) { // i can be referenced within { }, and within the for() control itself } for (int i = -1; i > -200; i--) { // this i is different from the i in the previous for-loop } Some computer language would allow you to declare a local variable with the same name as the global one (for example, there are global::X and local::X, but the code only refer as X). Most of the computer language would replace X with local::X at compile time, some would replace it with global::X) Some languages may not have the notion of local variables, everything is global, and some would not have the notion of global variable, but would provide a mean to act like one.


Describe the differences between local and module-level variables?

local Variable A Local variable is a variable whose scope is limited to the Block of the Subroutine defining it. Private Sub Command1_Click Dim a as integer End Sub Module Level Variable A Module Level variable is a variable whose scope is limited to the Form Module defining it. Public Sub Command1_Click Dim a as integer End Sub Global Level Variable A Global Level variable is a variable whose scope can be limited to the entire project defining it. Private Sub Classjnitialize () Dim a As Integer End Sub


What is a local variable and What statements are able to access a local variable?

A local variable is a variable that can only be called on by the module. Where as a global variable can be called upon by any module. Only statements made inside the same module can call on a local variable.


What is the difference between scope and need?

The difference in meaning between 'scope' and 'need' is as follows: the former denotes 'range' or 'spectrum' while also frequently implying vision -- or perception of some kind. By contrast, 'need' denotes 'lack' or 'unsatisfied desire.'

Related questions

What is the difference between local and global memory allocation?

global memory it is decide outside of your scope and we can access it in all of your scope


Which operator is allow to access hidden global variable?

The scope resolution operator, ::, overrides local scope and allows access to objects that are hidden due to global to local scope rules.


What is difference between local government and local self government?

The difference between local government and local self government is that local government has a more limited scope of power. Local self government is able to make more decisions.


Which group scope modifications in server 2003 are not permitted?

global to universal,universal of global, global to domain local


Difference of regular marketing from global marketing?

the main diffenrence of global and regular marketing is scope of activity....


What is the difference between scope and objectives?

scope is why to do and objective is how to do


What is the difference between Scope Of work and scope of services?

not sure


Why scope resolution is required in c?

Scope resolution is not required in C because C does not support namespaces. All non-local names are declared in the global scope.


Scope of static variables?

Scope of static variable is with in the file if it is static global. Scope of static variable is with in the function if variable is declared local to a function. But the life time is throughout the program


Difference between scope statement and project charter?

The difference between a scope statement and a project charter is that a project charter acknowledges the projects existence and the scope statement defines the project objectives.


What is the difference between local and global variable of C language?

4m Sai. Gloabal Variable is variable which is declared before main (). int a=10; main() { } here a is a global variable. where ever u r using this variable ... we'll get the value as 10. Local Variable is a variable which is declared inside the main(). int a=10; main() { int a=5; ........ ....... } here a=5 is a local variable and a=10 is called as global variable. then if u want to get a value... printf("%d",a); then result 'll be a=5; B'cos compiler gives main preference to local variables.. if any local declareation is not there then it 'll prefer global variable.


What is difference between scope and superscope?

Both are same no difference Both are same no difference