Home » C++ Programming » Variable Scope » Question
  1. What is the output of this program?
    #include 
    using namespace std;
    int glob = 12;
    int main()
    {
    int p;
    {
    int q;
    q = 13;
    p = 25;
    global = 35;
    cout << q<<" " << p<<" " < }
    p = 20;
    cout <<" "<< p<<" "<< glob;
    return 0;
    }
    1. 25 35 20 35
    2. 35 20 35
    3. Compilation Error
    4. 13 25 35 20 35
    5. None of these
Correct Option: D

The local values of p and glob within the block are more dominant than the global values.



Your comments will be displayed only after manual approval.