adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #include <iostream>
    using namespace std;
    int main()
    {
        char* buff;
        try 
        {
            buff = new char[1024];
            if (buff == 0)
               throw "Memory allocation failure!";
            else
               cout << sizeof(buff) << "Byte successfully allocated!"<<endl;
        }
        catch(char *strg)
        {
            cout<<"Exception raised: "<<strg<<endl;
        }
        return 0;
    }

a.

4 Bytes allocated successfully

b.

8 Bytes allocated successfully

c.

Memory allocation failure

d.

Depends on the size of data type

Answer: (d).Depends on the size of data type

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?