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

Explain how can you restore a redirected standard stream?

0 Answers  


A.C func() { pritnf(" in fuction %d",MACRO); } MAIN.c testfunc() { #define MACRO 10 printf("in test function %d", MACRO); } main() { printf("in main %d",MACRO); func(); testfunc(); getch(); }

2 Answers   Wipro,


Here is alphabets : abcdefgh 1) how to reverse. as hgfedcba 2) after reversal, how to group them in a pair hg fe dc ba.

2 Answers  


Why is c so important?

0 Answers  


Explain the use of #pragma exit?

0 Answers  






What is the difference between near, far and huge pointers?

0 Answers  


what is the need for main function in c?

5 Answers  


How can I convert a number to a string?

0 Answers  


what is the difference between call by value and call by reference?

5 Answers   Genpact, Global Logic, Infosys,


How do you declare a variable that will hold string values?

0 Answers  


What is the difference between i++ and i+1 ?(in terms of memory)

3 Answers   HCL,


What do you understand by friend-functions? How are they used?

0 Answers   iNautix,


Categories