What is a variable scope?
Scope of a variable Scope refers to the visibility of the variable. Broadly speaking it means in which region or which piece of code have access to that variable. There are generally two scopes of variables · Inside a function or a block which is called local variables, · Outside of all functions which is called global variables. Local Variables Variables that are declared inside a function or block are local variables. They can be used only by statements that are inside that function or block of code. Local variables are not known to functions outside their own. Following is the example using local variables: #include using namespace std ; int main () { // Local variable declaration: int a , b ; int c ; // actual initialization a = 10 ; b = 20 ; c = a + b ; ...