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

Answers were Sorted based on User's Feedback



What is the difference between a local and a global variable?..

Answer / rahul

Local Variables are declared within the function main.

main()
{
int a,b,c;(local variable declaration)

}
Global variables are declared outside the function main.

int FACT(int);
main()
{
Local variable declaration;
}

Is This Answer Correct ?    128 Yes 16 No

What is the difference between a local and a global variable?..

Answer / thiyagaraj.ramaswamy

Local Variable :
The scope or lifetime of the local variable
is with in a block or procedure..
Eg: DECLARE @Variable1

Global Variable :
The scope or lifetime of the global
variable throughout the execution of the program..
Eg: DECLARE @@Variable1

Is This Answer Correct ?    119 Yes 23 No

What is the difference between a local and a global variable?..

Answer / l.pandiyan

A global variable can be accessed by all functions. It is
initialized at the beginning of the program and is deleted
when the program shuts down. A local variable is isolated in
its function.

Is This Answer Correct ?    70 Yes 6 No

What is the difference between a local and a global variable?..

Answer / rattana

global variable can be accessed by all functions. local variable is isolated in its function.It is initialized at the beginning of the program and deleted when the program closed.

Is This Answer Correct ?    31 Yes 10 No

What is the difference between a local and a global variable?..

Answer / jaccessdenied

int a;//global variable
class VariablesDemo
{
int b;//class variable
void add()
{
int c,d;//c,d,e are local variables that are used within the function add
int e=c+d;
}
}

Is This Answer Correct ?    17 Yes 6 No

Post New Answer

More SQL Server Interview Questions

What are the diifferences between the ms sql server vs mysql?

0 Answers  


when you create a database how is it stored? : Sql server database administration

0 Answers  


Explain the phases a transaction has to undergo?

0 Answers  


When would you prefer to have a minimum number of indexes?

0 Answers  


tell me what is blocking and how would you troubleshoot it? : Sql server database administration

0 Answers  






Explain how many types of relationship?

0 Answers  


What is a full text index?

0 Answers  


Tell me about Triggers?

3 Answers   Cap Gemini,


Can you link only other SQL Servers or any database servers such as Oracle?

1 Answers  


Please give me queries for the following 1. To get the count of duplicate records. 2. A query to delete the duplicate records.

3 Answers   247Customer,


What is the meaning of resultset type_scroll_insensitive?

0 Answers  


What is 'Join' and explain its various types.

0 Answers   Genpact,


Categories