What is the scope of a variable ???? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the scope of a variable ????

Please give an example of each !!!!

3rd Dec 2017, 4:54 AM
Aman Jain
Aman Jain - avatar
1 Answer
+ 4
Scope generally refers to the program-region within which a variable is accessible. The broad rule is a variable is accessible within the set of braces it is declared in. For example: { int a; /* a would be accessible as long its block(pair of matching braces) is not closed */ } // using variable a here would give error
3rd Dec 2017, 5:29 AM
DAB
DAB - avatar