Best Answer

* These are all implementation defined. Access to `register' specified indentifiers should be as fast as possible, so the compiler may place the value in a machine register. However, the compiler is free to treat a `register' declaration as an `auto' declaration. * Where free memory is maintained is an OS specific concept. Instructions are generally stored in code segement. Local Variables are stored in Stack. Register variables are stored in Register. Global & static variables are stored in data segment. The memory created dynamically are stored in Heap And the C program instructions get stored in code segment.

User Avatar

Wiki User

โˆ™ 2005-10-30 03:39:34
This answer is:
User Avatar

Add your answer:

Earn +5 pts
Q: Where does global static local register variables free memory and C Program instructions get stored?
Write your answer...

Related Questions

Where are global local static extern variables stored?

AnswerLocal Variables are stored in Stack. Register variables are stored in Register. Global variables are stored in data segment. The memory created dynamically are stored in Heap And the C program instructions get stored in code segment and the extern variables also stored in data segment. Nooo NoooStatic variable will be stored in .BSS segment... (Block Started By Symbol)

What are global variable?

Variables that are declared globally outside every program are called global variables.

If most variables are local in a program instead of global the result is a program with low or high coupling?

Coupling is the interdependency of a program. A program that uses local variables is more independent than one that uses global variables. Therefore, the program would be considered to have lower coupling.

Where are global variables stored in memory?

Global variables don't have special place where it can be stored in. OS decides where to save it. Global variables are special only in the way that all blocks of your program can get access to it.

What is the difference between extern and global?

Extern and Global are the storage space in C program. Global provides us to access the variables from anywhere inside the program only whereas Extern provides us to access the variables from outside that program, i,e., some other program.

When possible you should advoid using what variables in a program?

Global Variables Or: variables with names longer than 128 characters.

What are the differences between global variables and local variables in C plus plus?

Global variables can be seen in all blocks of your program, when local variables are visible only within the block where it's declared.

When is better to use global variables rather than utilizing local variables in a program?

In my opinion it is rarely a good idea to use global variables, unless you need to refer to them across modules, or their values need to be keep for a long period of program execution. Local variables should always be used when their lifetime is short, usually only in the module they are declared in. Global variables lifetime will be for the length of the program execution.

Which components of program state are shared across threads in a multi-threaded process?

a. Register values b. Heap memory c. Global variables d. Stack memory

whose variables are also known as global variables?

The variables which are declared outside the main() function is known as global variables and they can be used anywhere in the program. And, the variables which used declare inside the main() function is known as local variables and they can be used inside the main() function only. Example: #include<stdio.h> #include<conio.h> int x,y; // global variables void main() { int a,b; // Local variables ------------ ---------------------- --------------------- getch(); }

What is the storage allocation and scope of global extern static local and register variables?

Extern is not a storage allocation specifier, it declares external linkage. That is, the declared variable or constant will be defined in a separate translation unit. Variables declared in global scope are allocated in static memory, as are all constants and static local variables. Local (non-static) variables are allocated on the (current) call stack. In multi-threaded applications, each thread has its own call stack. Register variables are automatic variables allocated within a CPU register, however the language compiler ultimately decides when or indeed if this is appropriate.

Why there are no global variables in java?

Global variables are globally accessible. Java does not support globally accessible variables due to following reasons:The global variables breaks the referential transparencyGlobal variables creates collisions in namespac

Where the constant variables stored in C?

constant variables are not stored anywhere..where ever they r present in the program the compilier at compilation time replaces these varibles by their values...however the local variables are stored in stack memory & global and static variables are stored in data segement of the program....

What are the different storage class in c?

The four storage classes in C are: automatic, static, external and register. Note that storage classes are not classes in the object-oriented programming sense, they simply define the scope (visibility) of a variable.Automatic Variables (auto)All local variables are automatic by default so we seldom see the auto keyword in code. Local variables are variables declared at function scope.Static Variables (static)All global variables are static by default. Global variables are variables declared at file scope (outside of any function). Static variables can also be explicitly declared inside functions to override the default automatic storage class. All static variables, whether global or local, are allocated within the program's data segment (static memory) and do not fall from scope even if declared locally. All static variables are initialised to zero by default.It's best to avoid the use of global variables unless they are declared constant (const) as it can be difficult to keep track of all the places where a global variable is being operated upon (accessed or assigned to). This can lead to data races in multi-threaded applications unless we take steps to synchronise all access and assignment operations upon the variable. For that reason it's best to keep variables as localised as possible, passing arguments into functions whenever we need to cross scopes. Non-constant global variables should really only be considered if they truly represent a global concept within the file in which they are declared.External Variables (extern)External storage can only be applied to a global variable declared outwith file scope. That is, when a global variable is declared in one file, any external file can gain access to that same global variable simply by declaring the same name and type but with external storage. It follows that external variables are also static variables and is the only case where a variable has two storage classes. Note the local static variables (including local constant variables) cannot be declared external, they are local to the function in which they are declared.This is another reason why it is best to avoid using too many global variables. While we can generally keep track of which code can access a global variable at file scope we have no means of limiting access from outwith that file. Again, prefer local variables to global variables whenever possible.Register Variables (register)A register variable is a variable that we wish to allocate to a CPU register rather than in RAM. Register variables must be no larger than the word-length of the machine and should only be used when we explicitly require fast access to the variable, such as loop counters, accumulators and pointer variables. Note that CPU registers have no address (no identity we can refer to) so we cannot use the unary '&' operator to take the address of a register variable. This means we cannot use pointers to refer to them indirectly which, in turn, means we can only pass them to functions by value (not by reference). However, to do so would defeat the purpose of using the register storage class.Given the limited number of registers available, there is no guarantee that a register variable will actually be allocated to a register; the register keyword is merely a hint to the compiler. It should be noted that modern compilers are extremely good at optimising code so there is seldom any need to explicitly declare register variables.

What is the Conceptual Memory Map of a C Program?

C++ has 4 distinct regions for memory distribution Stack : This region is used for function calls' return addresses , arguments and local variables Heap : This region is for dynamic allocation of memory (dynamic variables created on run time use this memory , aka RAM) Global Variables : This is used for global variables defined by the programmer Program Code : This region is for the program code.

Global variable definition in C plus plus?

Global variables can be seen in all blocks of your program, when local variables are visible only within the block where it's declared. hope this helps ...harry hill

Why do global variables make a program difficult to debug?

The term variables imply that those things may be changed or assigned with new value (at numerous places). This make the program harder to debug because it will be difficult to know when and where a global variable being changed and what was the consequence of that value changed.

What is auto declaration in C?

Auto is one of the four storage classes in c. This is the default storage class. The auto storage class can be used only inside functions, i.e. only to declare local variables and not to declare global variables. All the local variables are by default auto variables. Other storage classes are: Register - variables declared may get stored in CPU registers instead of RAM Static - default storage class for global variables extern - defines global variables that is visible to all object modules

What is the other name of global variables?

Another name of global variable is "EXTERNAL VARIABLES".

How do you create a global variable in a program?

1.In computer programming, a global variable is a variable that is accessiblein every scope.2.There are some variables that are used in more than one function.suchvariables are called global variables.3.Usually,they are declared in global declaration section that is outsideof all functions.4.In this section,we can also declare all user-defined functions.DECLARATION:int global =5;

What are global variables in c language?

Global variables are named storage locations that are allocated (and possibly initialized) when the program is loaded. Global variables are accessible by name from within any function. In C source, a global is a variable that is declared outside of any function, without an extern or static storage class specifier.The use of global variables without good justification is generally considered bad programming style, as it creates cohesion between functions and between modules, allows functions to have side-effects, and causes lots of confusion if some functions declare automatic variables with the same names as global variables.

What are global and local 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.

What are global variables explain with examples?

Variables that the program can use everywhere in the program. Example: int x = 5; int main(void) { x = 6; foo(); return 0; } void foo(void) { x = 5; }

What are local variables and global variables?

In programming, local variables are those that are only accessible within a particular (not global) scope, while global variables are those accessible from anywhere within the same program.In the C programming language, global variables are all those declared at a file (module) level but not constraint with the static keyword.Variables declared at a file level but constraint by the static keyword are sometimes called file-global and sometimes called file-local variables.In the C programming language, all other variable declarations occur either within a function argument list declaration, or within a pair of curly braces. The function, and the pair of curly braces, defines the scope of the variable definition.As each variable must have a unique name within its scope, global variables' names must be unique within the entire program, while other variables' names must be unique within their declaration scope (the file, the function, the pair of curly braces).

How can you declare global and local variables in pseudcode?

You declare global and local variables in pseudocode the same way you declare them in real code. You place local variables within blocks, and you place global variables outside of all blocks.