What is the difference between a local and a global variable?
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
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 |
What are the diifferences between the ms sql server vs mysql?
when you create a database how is it stored? : Sql server database administration
Explain the phases a transaction has to undergo?
When would you prefer to have a minimum number of indexes?
tell me what is blocking and how would you troubleshoot it? : Sql server database administration
Explain how many types of relationship?
What is a full text index?
Tell me about Triggers?
Can you link only other SQL Servers or any database servers such as Oracle?
Please give me queries for the following 1. To get the count of duplicate records. 2. A query to delete the duplicate records.
What is the meaning of resultset type_scroll_insensitive?
What is 'Join' and explain its various types.