Question: #include using namespace std; // Function prototype double divide(int, int); int main() { int num1, num2; // To hold two numbers double quotient; // To

#include using namespace std;

// Function prototype double divide(int, int);

int main() { int num1, num2; // To hold two numbers double quotient; // To hold the quotient of the numbers

// Get two numbers. cout << "Enter two numbers: "; cin >> num1 >> num2;

// Divide num1 by num2 and catch any // potential exceptions. try { quotient = divide(num1, num2); cout << "The quotient is " << quotient << endl; } catch (char *exceptionString) { cout << exceptionString; }

cout << "End of the program. "; return 0; }

//******************************************** // The divide function divides numerator by * // denominator. If denominator is zero, the * // function throws an exception. * //********************************************

double divide(int numerator, int denominator) { if (denominator == 0) throw "ERROR: Cannot divide by zero. ";

return static_cast(numerator) / denominator; }

C++

What problem is it when denominator equals 0?

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 Databases Questions!