-
What is the output of this program?
#include <iostream>
using namespace std;
double DivFunction(int num1, int num2)
{
if ( num2 == 0 )
{
throw "Division by zero condition Occurred...";
}
return (num1 / num2);
}
int main ()
{
int m = 10;
int n = 0;
double Res = 0;
try
{
Res = DivFunction(m, n);
cout << Res << endl;
}
catch (const char* msg)
{
cout << msg << endl;
}
return 0;
}
-
- Compilation Error
- Runtime Error
- Division by zero condition Occurred...
- Garbage value
- None of these
Correct Option: C
We are dividing the values and if one of the values is zero means, We are arising an exception.