What is meant by the phrase "the scope of a variable" and how does it relate to subroutines and modules?
![]() |
What is meant by the phrase "the scope of a variable" and how does it relate to subroutines and modules?
Useful read: http://en.wikipedia.org/wiki/Scope_(computer_science)
Hello!
The scope of a variable mean wher in the program your variable will be accessible to your code. Depending where it is declare the scope will vary,if you declare it into a function it will be available only into that function, if you declare it into a loop you will be able to use it only into that loop, if you declare it before main() it will be global and accessible every where into the program but global variable are rarely the way to go.
hope this was helpful
All times are GMT -7. The time now is 08:14 PM. |