72.
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
namespace Box1
{
    int a = 4;
}
namespace Box2
{
    int a = 13;
}
int main ()
{
    int a = 16;
    Box1::a;
    Box2::a;
    cout << a;
    return 0;
}

73.
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
namespace A{
 
	int var = 10;
}
namespace B{
	int var = 5;
}
int main()
{
	using namespace B;
	cout<<var;
}

74.
What will be the output of following C++ code?
#include <iostream>
#include <string>
using namespace std;
namespace My_old_school_and_college_friends_number
{
	long int f1 = 9999999999;
	long int f2 = 1111111111;
}
namespace contacts = My_old_school_and_college_friends_number;
int main(){
 
	cout<<contacts::f1;
}

75.
What will be the output of the following C++ code?
#include <iostream>
#include <exception>
using namespace std;
int main()
{
    try 
    {
        int * array1 = new int[100000000];
        int * array2 = new int[100000000];
        int * array3 = new int[100000000];
        int * array4 = new int[100000000];
        cout << "Allocated successfully";
    }
    catch(bad_alloc&) 
    {
        cout << "Error allocating the requested memory." << endl;
    }
    return 0;
}

76.
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
double division(int a, int b)
{
    if (b == 0) 
    {
        throw "Division by zero condition!";
    }
    return (a / b);
}
int main ()
{
    int x = 50;
    int y = 2;
    double z = 0;
    try 
    {
        z = division(x, y);
        cout << z;
    }
    catch(const char *msg) 
    {
        cerr << msg;
    }
    return 0;
}

Read More Section(Functions and Procedures in C plus plus)

Each Section contains maximum 100 MCQs question on Functions and Procedures in C plus plus. To get more questions visit other sections.