Home » C++ Programming » Exception Handling » Question
  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    double Div(int num1, int num2)
    {
    if (num2 == 0)
    {
    throw "Division by zero condition!";
    }
    return (num1 / num2);
    }
    int main ()
    {
    int p = 40;
    int q = 0;
    double R = 0;
    try
    {
    R = Div(p, q);
    cout << R << endl;
    }
    catch (const char* Message)
    {
    cerr << Message << endl;
    }
    return 0;
    }
    1. 40
    2. Division by zero condition!
    3. Compilation Error
    4. Runtime Error
    5. None of these
Correct Option: B

NA



Your comments will be displayed only after manual approval.