/* */ Click to Join Live Class with Shankar sir Call 9798158723

What is Local scope ?


Variables which are define inside a function or a block are called local variables . These local variables can only be used with in the function or block in which these are declared. or Anything between ‘{‘ and ‘}’ is said to inside a block.

Q.) Example of Local Variables in C++ .
    
    #include< iostream>
    using namespace std;

    // Global variable  
    int a = 3; 

    int main()
    {
      // Local variable   
      int a = 7;
      cout << "Value of global variable a is " << ::a<< endl;
      cout<< "Value of local variable a is " << a; 
      return 0;
    }

Output
Value of global variable a is 0
Value of local variable a is 10