answersLogoWhite

0


Best Answer

There are two ways to declare varibles.

1. Locally

2. Globally When you declare a variable locally in any function that means it is only accessible by that function. When you declare a variable globally so it is accessible by all the functions in the program. Declaring variables with static keyword means you are setting its value null.

User Avatar

Wiki User

2007-09-06 08:14:31
This answer is:
User Avatar
Study guides

What is a programming language

What does DOS stand for

What is a software that is distributed for free

What do unix and Linux have in common

➡️
See all cards
3.91
53 Reviews

Add your answer:

Earn +20 pts
Q: What is the difference between declaring static variable as local and global?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the difference between a global variable and a private variable?

The accessibility. The global one: almost everywhere in the code may reference to the global variable directly. The private variable, is private to the declaring module (class, method, assembly) only. Outside of that module has no access to it directly.


What is the difference between global and local variable?

Their scope.


What is the difference between static variable and global variable?

static variable is available to the module where it is defined. Global variable is available through out the pgm


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.


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 Difference between global variable and environment variable?

Global variables are system-wide variables set by the OS at start-up, and can't be modified. Environmental variables are variables that are system-wide, but can be modified.


Difference between static variable and automatic variable?

In C programming, a static variable declared outside of any function is global, but local to the current module. A static variable declared within a function retains its value between function calls.


What is the difference between extern global variable and static global variable in c?

extern variables are defined in different than the file where the main() is. extern variables can be accessed from other files. Static global variables are visible only within the file.


Difference between Global variable and Static Global variable in c?

Global (file scope) variable and static global variables both retain their value for the duration of the program's execution. Static global variables are visible only to functions within the file they are declared, while global variables are visible to all compilation units (files) within the linked load module.


Difference between global and transnational strategy?

the difference between global and international strategy


Difference between international and global communication?

what is the difference between international communication and global communication


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.

People also asked