adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #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.

None of the mentioned

Answer: (c).Depends on the memory of the computer

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?