answersLogoWhite

0


Best Answer

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

User Avatar

Wiki User

2010-01-18 12:07:35
This answer is:
User Avatar
Study guides
📓
See all Study Guides
✍️
Create a Study Guide
4.25
12 Reviews

Add your answer:

Earn +20 pts
Q: What are the differences between global variables and local variables in C plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What are the differences between global and local winds?

glo


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.


What is the difference between static variable and global variable declaration?

When you say static variable, do you mean local static variable or global static variable? In C, the difference between global static variables and global variables is that static in this case means that the variable can be used only in the module (.c file) that it is declared. The difference between a local static variable and a global variable is the scope: the local variable can be used only inside the function that declares it. So you can have 2 local static variables in the same file with the same name but in different functions and they will be 2 different variables.


Are C variables initialized to 0 by default?

Only global/static variables are, local variables aren't.


What is the difference between a static variable a global variable and a local variable?

A static variable is a variable allocated in static storage. A local variable is a variable declared inside a function. A global variable is a variable declared outside of any class or function. Note that local variables and global variables can both be allocated in static storage.


What is the main difference between local variables and global variables show briefly?

A global variable can be seen in any scope. Local variables can be seen only in their scopes and any sub-scopes. ex: int x; //global: visible in all scopes void func() { //scope 1 int y; // local: visible in scope 1 and scope 2 { //scope 2 int z; // local: visible *only* in scope 2 } }


How do you hide local variables in c and give precedence to global variables inside the function?

Hi, I would like to answr the question.So, if you want the to give more precedence to global variables with respect to a local one.Just add a pair of curly braces in the local variable and by doing so u can access global variable.


Where are local and global variables stored?

RAM = Random Access 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(); }


How can you declare global an local variables in flowcharts?

Global and local variables can be displayed in flowcharts typically as overlays or in region specific flowcharts. General flowcharts on the base chart cannot accommodate multiple variations.


How can you declare global and local variable in flowcharts?

In Raptor: Global variables are to be displayed in the assignment window, while the local ones need to be input into the input box.


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.

People also asked