adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #include <iostream>
    using namespace std;
    int main()
    {
        int a = 10, b = 20, c = 30;
        float  d;
        try
        {
            if ((a - b) != 0)
            {
                d = c / (a - b);
                cout << d;
            }
            else
            {
                throw(a - b);
            }
        }
        catch (int i)
        {
            cout<<"Answer is infinite "<<i;
        }
    }

a.

10

b.

-3

c.

15

d.

none of the mentioned

Answer: (b).-3

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?