4. Determine the output of each of the following program when it is executed. (a) #include using namespace std; namespace { int a; namespace { int a; } } int main() { } (b) a = 10; cout ...




4. Determine the output of each of the following program when it is executed. (a)


#include using namespace std; namespace {


int a; namespace {


int a;


}


}


int main()


{










}


(b)




a = 10;


cout <><><>




#include using namespace std; namespace A {


int a = 10; void display();


}


namespace B { int a = 100;


void display();


}


void A:: display()


{


cout <><>


}




void B:: display()


{


cout <><>


}




int main()


{










}


(c)




A::display();


B::display(); return 0;




#include using namespace std; namespace X {


int a = 10; namespace Y {


int a = 20;


}


}










int main()


{










}


(d)




cout <><>


cout <><>


return 0;




//using unnamed namespace #include


using namespace std; namespace {


int a = 10;


}


namespace {


int b = 100;


}


void display1()


{


cout <><>


}




void display2()


{


cout <><>


}




int main()


{










}


(e)




display1(); display2(); return 0;




//using unnamed namespace #include


using namespace std; namespace {


int a = 10; namespace {


int a = 20; namespace {


int a = 30; namespace {


int a = 40;


}


}


}


}


void display()


{


cout <><>










}


int main()


{








}


(f)




display(); return 0;




// using


#include using namespace std; namespace rst


{


int x = 5; int y = 10;


}


namespace second


{


double x = 3.1416; double y = 2.7183;


}


int main ()


{


















}


(g)




using rst::x; using second::y cout <>endl; cout <> endl;


cout <><><>endl; return 0;




// using namespace #include using namespace std; namespace rst


{


int x = 5;


}


namespace second


{


double x = 3.1416;


}


int main ()


{


{


using namespace rst; cout <> endl;


}


{


using namespace second; cout <> endl;


}


return 0;


}










May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here