Home » C++ Programming » Exception Handling » Question
  1. What is the output of this program?
     #include 
    #include
    using namespace std;
    int main()
    {
    try
    {
    int * arr1 = new int[100000000];
    int * arr2 = new int[100000000];
    int * arr3 = new int[100000000];
    int * arr4 = new int[100000000];
    cout << "Memory Allocated successfully";
    }
    catch(bad_alloc&)
    {
    cout << "Error allocating the requested memory." << endl;
    }
    return 0;
    }
    1. Depends on the memory of the computer
    2. Allocated successfully
    3. Error allocating the requested memory
    4. All of above
    5. None of these
Correct Option: A

In this program, we allocating the memory to the arrays by using exception handling and we handled the exception by standard exception.



Your comments will be displayed only after manual approval.