+ 1

What are local and global variables?

c++

1st Dec 2016, 1:26 PM
Fahmeen Mazhar
Fahmeen Mazhar - avatar
2 Answers
+ 1
Global variables are declared outside any function, and they can be accessed (used) on any function in the program. Local variables are declared inside a function, and can be used only inside that function. 
1st Dec 2016, 1:43 PM
Aliakbar Rezapour
Aliakbar Rezapour - avatar
0
Any variable which is inside a specific function is said to be local variable of that function.Any variable called outside a specific function say which is in main function and can be used anywhere in program is global function.
1st Dec 2016, 1:31 PM
Ashwini Nayak
Ashwini Nayak - avatar