Variable Scope


  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. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

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