7. Consider the following code: // Exception handling { std::cout < < STL exception time; double factor

Question:

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.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: