answersLogoWhite

0


Best Answer

If you define a variable inside of your function, the variable can be referred and used only inside of that function. It means that you will not able to use the variable in another function (including main). Area of code where your variable can be used after declaration is usually called visibility of the variable.

User Avatar

Wiki User

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

Wiki User

14y ago

The part of the code in which the variable is available.

This answer is:
User Avatar

User Avatar

Wiki User

8y ago

Global scope (with external linkage).

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Explain the scope and visibility of variables in c plus plus function?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Which variable is not destroyed on exit from the function instead its value is presented and becomes available again when the function is next called These variables are declared as?

Local function variables defined static remain in memory at all times. Such variables are only in scope (accessible) when the function itself is in scope.


What enables us to use a function that has been declared and defined in source code?

If the function has been declared and defined, then the only remaining issue is scope, i.e. visibility.


What is the scope of any variable?

The Scope of a variable defines the areas of a program where this variable would be visible and can be used. For ex: a. Method variables - are visible only inside the method where they are declared and hence their scope is only the method b. Class variables - are visible inside the class and can be used by any method inside the class and hence their scope is the whole class.


What is meant by delare or initialize a variable or constant at a lowest possible level?

It probably refers to "scope" (see http://en.wikipedia.org/wiki/Scope_(programming)). In programming languages with lexical scope, variables declared in an outer scope can be used in an inner scope, but variables declared in an inner scope cannot be used in outer scopes. It is considered best practice to declare variables (and constants, which are just variables that don't change) at the innermost scope possible for several reasons: # It makes it most clear what the scope of use is of the variable. # It makes it impossible to mistakenly use it in some other location. # It makes it easier to keep track of what variables exist at any given point in the code. For example, in standard C, nested functions are not allowed. This means that in any function, only two types of variables exist - global variables, and variables declared within that function. This has the advantage of making it easy to understand what any variable refers to.


Examples of automatic variables in c?

Automatic variables are variables that are declared within the scope of a block, usually a function. They exist only within that scope, i.e. that block, and they cease to exist after the block is exited. These variables are usually allocated from the stack frame.

Related questions

Which variable is not destroyed on exit from the function instead its value is presented and becomes available again when the function is next called These variables are declared as?

Local function variables defined static remain in memory at all times. Such variables are only in scope (accessible) when the function itself is in 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


Can you explain the nature and scope of the product or service management function?

bush


What enables us to use a function that has been declared and defined in source code?

If the function has been declared and defined, then the only remaining issue is scope, i.e. visibility.


What is the scope of any variable?

The Scope of a variable defines the areas of a program where this variable would be visible and can be used. For ex: a. Method variables - are visible only inside the method where they are declared and hence their scope is only the method b. Class variables - are visible inside the class and can be used by any method inside the class and hence their scope is the whole class.


What is meant by delare or initialize a variable or constant at a lowest possible level?

It probably refers to "scope" (see http://en.wikipedia.org/wiki/Scope_(programming)). In programming languages with lexical scope, variables declared in an outer scope can be used in an inner scope, but variables declared in an inner scope cannot be used in outer scopes. It is considered best practice to declare variables (and constants, which are just variables that don't change) at the innermost scope possible for several reasons: # It makes it most clear what the scope of use is of the variable. # It makes it impossible to mistakenly use it in some other location. # It makes it easier to keep track of what variables exist at any given point in the code. For example, in standard C, nested functions are not allowed. This means that in any function, only two types of variables exist - global variables, and variables declared within that function. This has the advantage of making it easy to understand what any variable refers to.


Examples of automatic variables in c?

Automatic variables are variables that are declared within the scope of a block, usually a function. They exist only within that scope, i.e. that block, and they cease to exist after the block is exited. These variables are usually allocated from the stack frame.


What are the advantages of local variables in programming?

1. Local variables cannot be used by other forms. 2. Cannot be used globally. 3. They can slowdown the compiling process.


What is prefix of function?

A function that is used before an variable to increase or decrease its value


What is the scope of register variables?

The block they are declared in.


What are local variables and global variables?

Local variables: These variables only exist inside the specific function that creates them. They are unknown to other functions and to the main program. As such, they are normally implemented using a stack. Local variables cease to exist once the function that created them is completed. They are recreated each time a function is executed or called. Global variables: These variables can be accessed (ie known) by any function comprising the program. They are implemented by associating memory locations with variable names. They do not get recreated if the function is recalled.


Explain nature and scope of business economics?

Explain the nature & scope of business economics.