Home » C++ Programming » Exception Handling » Question
  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    int main()
    {
    char* p;
    unsigned long int test = sizeof(size_t(0) / 3);
    cout << test << endl;
    try
    {
    p = new char[size_t(0) / 3];
    delete[ ] p;
    }
    catch (bad_alloc &BadAllocation)
    {
    cout << BadAllocation.what() << endl;
    };
    return 0;
    }
    1. 8
    2. 4
    3. 2
    4. 1
    5. Depends on compiler
Correct Option: E

The size of unsigned long int always depends on compiler.



Your comments will be displayed only after manual approval.