Home » C++ Programming » Exception Handling » Question
  1. What is the output of this program?
    #include 
    using namespace std;
    int main()
    {
    int num = 20;
    try
    {
    if (num != 20)
    {
    throw "Positive Number Required";
    }
    cout << num;
    }
    catch(const char *Msg)
    {
    cout << "Error: " << Msg;
    }
    return 0;
    }
    1. Compilation Error
    2. Runtime Error
    3. Garbage value
    4. error:Positive Number Required
    5. None of these
Correct Option: D

As the zero marks the beginning of the positive number, it is printed as output



Your comments will be displayed only after manual approval.