Examveda

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;
}

A. Allocated successfully

B. Error allocating the requested memory

C. Depends on the memory of the computer

D. Error

Answer: Option C


Join The Discussion

Related Questions on Functions and Procedures in C plus plus