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

Is reference used in C?

1 Answers  


write a program to copy a string without using a string?

2 Answers  


how can u print a message without using any library function in c

1 Answers   NIIT,


When should the const modifier be used?

0 Answers  


whitch value return void main?

11 Answers  






in which language c language is written?

2 Answers  


Why do we need a structure?

0 Answers  


how to find a 5th bit is set in c program

4 Answers   IBM,


Which driver is a pure java driver

0 Answers   Vertex,


write an interactive C program that will encode or decode a line of text.To encode a line of text,proceed as follows. 1.convert each character,including blank spaces,to its ASCII equivalent. 2.Generate a positive random integer.add this integer to the ASCII equivalent of each character.The same random integer will be used for the entire line of text. 3.Suppose that N1 represents the lowest permissible value in the ASCII code,and N2 represents the highest permissible value.If the number obtained in step 2 above(i.e.,the original ASCII equivalent plus the random integer)exceeds N2,then subtract the largest possible multiple of N2 from this number,and add the remainder to N1.Hence the encoded number will always fall between N1 and N2,and will therefore always represent some ASCII character. 4.Dislay the characters that correspond to the encoded ASCII values.  The procedure is reversed when decoding a line of text.Be certain,however,that the same random number is used in decodingas was used in encoding.

0 Answers  


Write a programe print the sum of series 0,1,2,.....10

7 Answers  


Define a structure to store roll no, name and marks of a student. Using the structure of above write a ‘C’ program to create a file “student.dat”. There must be one record for every student in the file. Accept the data from the user.

0 Answers  


Categories