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 |
How to write a query with an inner join in ms sql server?
how to write test cases for testing databases,especially for testing and writing test cases for stored procedures.any real time database testers.please answer me.
Find columns used in stored procedure?
Does view occupy space?
How to create hyperlink from returned sql query ?
How to use column default values in insert statements in ms sql server?
What is a sql join?
Explain the basic concepts of SQL server architecture?
2 Answers College School Exams Tests,
How many index keys possible for a table
Please tell me some knowledge about Clustering and how to add clustering?
What is use of except clause? How it differs from not in clause?
How do you make a trace?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)