adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #include <iostream>
    using namespace std;
    void test(int x)
    {
        try
        {
            if (x > 0)
                throw x;
            else
                throw 'x';
        }
        catch(int x)
        {
            cout<<"integer:"<<x;
        }
        catch(char x)
        {
            cout << "character:" << x;
        }
    }
    int main()
    {
        test(10);
        test(0);
    }

a.

integer:10character:x

b.

integer:10

c.

character:x

d.

none of the mentioned

Answer: (a).integer:10character:x

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?