Question: 7. Consider the following code: // Exception handling { std::cout < < STL exception time; double factor = 2.0; double val = factor*std::numeric_limits ::max(); //

7. Consider the following code:

// Exception handling

{

std::cout << "STL exception time";

double factor = 2.0;

double val

= factor*std::numeric_limits::max(); // infinity val -= val; // NaN try

{

double b = std::exp(val);

}

catch (std::domain_error& e)

{

// 1.

std::cout << "Error " << e.what() << std::endl;

}

catch (...)

{

// 2.

std::cout << "Unexpected error " << std::endl;

}

std::cout << "end " << std::endl;

}

When this code is run, what happens?

a) A domain error occurs.

b) An unexpected error occurs.

c) The program crashes.

d) The program runs to completion without throwing an exception.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting For Financial Instruments Questions!