3. What will be the output of each of the following program when it is executed. (a) #include using namespace std; int a = 10; namespace X { int a = 20; } namespace Y { int a = 30; } int main() { ...




3. What will be the output of each of the following program when it is executed. (a)


#include using namespace std; int a = 10; namespace X {


int a = 20;


}


namespace Y {


int a = 30;


}


int main()


{


















}


(b)




++::a;


++X::a;


++Y::a;


cout <><>


cout <><>


cout <><><>




#include using namespace std; int a = 10; namespace X {


int a = 20;










}


namespace Y {


int a = 30;


}


int main()


{












}





cout <><>


cout <><> ‘\n’;


cout <><> ‘\n’;


return 0;




#include using namespace std; int a = 10; namespace X {


int a = 20;


}


namespace Y {


int a = 30;


}


int main()


{












}


(d)




cout <><>


cout <><> ‘\n’;


cout <><> ‘\n’;


return 0;




#include using namespace std; namespace {


int a = 20;


}


namespace {


int *ptr;


}


int main()


{










}





ptr = &a;


cout <><> ‘\n’; return 0;




#include using namespace std; namespace {


int a = 20;


}


namespace {


int *ptr;


}


int main()


{




















}



(f)




ptr = &a;


cout <><> ‘\n’; return 0;




#include using namespace std; namespace X {


int a = 20;


}


namespace Y {


int *ptr;


}


int main()


{










}



(g)




Y::ptr = &(++X::a);


cout <><><>




#include using namespace std; namespace X {


int a; namespace Y {


int a;


}


}


int main()


{














}



(h)




X::a = 10;


Y::a = 20;


cout <><>


cout <><><>




#include using namespace std; namespace {


int a; namespace {


int b;


}


}


int main()


{


a = 10;


b = 20;


cout <><><><><><>


}










May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here