What are local and global variables?

Answers were Sorted based on User's Feedback



What are local and global variables?..

Answer / udayakumar

local variables are the variables which are declared with in
a function and the scope of that variables are only within
that function.Global variables are the variables which are
declared globally.Since it is declared globally it can
accessible to all the functions inside the program...

Is This Answer Correct ?    3 Yes 0 No

What are local and global variables?..

Answer / ashish

Local:-
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:-
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.

Is This Answer Correct ?    2 Yes 0 No

What are local and global variables?..

Answer / pushpendra

local variable:-its uses inside the function that is these variable exist inside the function and other fu no access out side the main function.
while global variables are variables and which are declared both sides of function inside and outside that is globally.all functions can access out of main function.

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More C Interview Questions

What is %d used for?

0 Answers  


Write a program that takes a 5 digit number and calculates 2 power that number and prints it.

1 Answers  


Explain enumerated types in c language?

0 Answers  


How can you find the day of the week given the date?

0 Answers  


How can you allocate arrays or structures bigger than 64K?

0 Answers  






i want explaination about the program and its stack reprasetaion fibbo(int n) { if(n==1 or n==0) return n; else return fibbo(n-1)+fibbo(n-2); } main() { fibbo(6); }

2 Answers  


What is omp_num_threads?

0 Answers  


When do you say that a digraph is acyclic A)if and only if its first search does not have back arcs B)a digraph is acyclic if and only if its first search does not have back vertices C)if and only if its first search does not have same dfnumber D)None of these

1 Answers   Accenture, IBM,


What is a constant and types of constants in c?

0 Answers  


What is the difference between array and structure in c?

0 Answers  


What is the difference between malloc calloc and realloc in c?

0 Answers  


Differentiate Source Codes from Object Codes

1 Answers  


Categories