What is meant by global static? why we have to use static
variable instead of Global variable

Answers were Sorted based on User's Feedback



What is meant by global static? why we have to use static variable instead of Global variable..

Answer / guest

Static is protected one and you cannot acess the variable
in other files/functions.It is declared in the top of the
file/function.The value retains tho,t the program.

Is This Answer Correct ?    6 Yes 0 No

What is meant by global static? why we have to use static variable instead of Global variable..

Answer / vaibhav

global static means the static value declared as a
global.using this we can share same copy of that variable.

Is This Answer Correct ?    1 Yes 1 No

What is meant by global static? why we have to use static variable instead of Global variable..

Answer / indira amit

Variables defined local to a function disappear at the end
of the function scope. So when we call the function again,
storage for variables is created and
values are reinitialized. So if we want the value to be
extent throughout the life of a program, we can define the
local variable as "static." Initialization is performed only
at the first call and data is retained between func calls.

Had it been gloal variable, it would have been available
outside the scope of the function, but static variable is
not available outside the scope of a function (helpful in
localizing errors - as it can't be changed outside the func
scope).

Is This Answer Correct ?    0 Yes 0 No

What is meant by global static? why we have to use static variable instead of Global variable..

Answer / abdur rab

Static remains throughout the program, however its scope is
limited to that file alone. If a program consists of
multiple files, you want a variable to be seen by the
entire file and do not want that variable to be seen by the
other files, then mark is as static

static int a;

as a global variable

Is This Answer Correct ?    2 Yes 3 No

Post New Answer

More C Interview Questions

Write any data structure program (stack implementation)

1 Answers   HTC,


what defference between c and c++ ?

6 Answers  


What is an example of enumeration?

1 Answers  


If I want to initialize the array like. int a[5] = {0}; then it gives me all element 0. but if i give int a[5] = {5}; then 5 0 0 0 0 is ans. what will I do for all element 5 5 5 5 5 in a single statement???

3 Answers   Amdocs, IBM,


Write a program to produce the following output in c language? 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1

2 Answers  


in a town the percentage of men is 52 the percentage of total literacy is 48 if total percentage of literate men is 35 of the total population write a program to find the total no of the literate men and women if the population of the town is 80000

3 Answers  


#include<stdio.h> #include<conio.h> struct stu { int i; char j; }; union uni { int i; char j; }; void main() { int j,k; clrscr(); struct stu s; j=sizeof(s); printf("%d",j); union uni u; k=sizeof(u); printf("%d",k); getch(); } what is value of j and k.

2 Answers   Facebook,


What is the difference between far and near ?

0 Answers  


Explain 'bus error'?

0 Answers  


Can you explain what keyboard debouncing is, and where and why we us it? please give some examples

0 Answers   CSC, Wipro,


input may any number except 1,output will always 1.. conditions only one variable should be declare,don't use operators,expressions,array,structure

4 Answers   IBM,


Explain what is the difference between text files and binary files?

0 Answers  


Categories