-
What is the output of this program?
#include <iostream>
using namespace std;
void DivFunction(const double num1, const double num2);
int main()
{
double option1=20, option2=5;
try
{
DivFunction(option1, option2);
}
catch (const char* S)
{
cout << "Bad Operator caught: " << S;
}
return 0;
}
void DivFunction(const double num1, const double num2)
{
double Res;
if (num2 == 0)
throw "Division by zero not allowed";
Res = num1 / num2;
cout << Res;
}
-
- Bad Operator caught
- Division by zero not allowed
- 10
- 20
- 4
Correct Option: E
We are dividing 20 and 5 in this program and we are using the throw statement in the function block.