-
What is the output of this program?
#include <iostream>
using namespace std;
int main()
{
double num1 = 9, num2 = 3, Result;
char Operator = '/';
try
{
if (num2 == 0)
throw "Division by zero not allowed";
Result = num1 / num2;
cout << num1 << " / " << num2 << " = " << Result;
}
catch(const char* S)
{
cout << "\n Bad Operator: " << S;
}
return 0;
}
-
- 9
- 3
- 9 / 3 = 3
- Bad Operator
- None of these
Correct Option: C
In this program, We are dividing the two variables and printing the result. If any one of the operator is zero means, it will arise a exception.