Given the following code, what will happen if the value of denom is 0?
double divide(int numer, int denom)
{
if (denom == 0)
throw "ERROR: Cannot divide by zero.\n";
else
Return static_cast<double>(numer) /denom;
}
A) Nothing will happen because there is no catch block.
B) The program will display ERROR: Cannot divide by zero.and then move to the statement following the if/else block.
C) The program will display ERROR: Cannot divide by zero.and then halt.
D) There is no throw point because there is no try block.
E) None of these
Correct Answer:
Verified
Q10: When an error occurs, an exception is
A)
Q11: Function templates allow you to write a
Q12: There is no difference between declaring an
Q13: Using a function template requires less code
Q14: If an exception is thrown by a
Q16: The line containing a throw statement is
Q17: In the following code, which statement
Q18: Exceptions are used to signal errors or
Q19: The _ starts with the key word
Q20: A program may not contain both a
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents