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 |
explain different types of backups avaialabe in sql server? Given a particular scenario, how would you go about choosing a backup plan? : Sql server database administration
Difference between primary key and clustered index?
what is the sql equivaent of the dataset relation object ?
What is attribute relationships, why we need it? : sql server analysis services, ssas
What is difference between materialized view and view?
Can an automatic recovery be initiated by a user?
Explain what is the use of custom fields in report?
Do you know what is normalization of database? What are its benefits?
Explain what are the database objects? : SQL Server Architecture
If a stored procedure is taking a table data type, how it looks?
What is an index in sql?
What is temporal data type?