Sail E0 Webinar
Question


What is the output of this program?


1.
#include
2.
using namespace std;
3.
void Division(const double a, const double b);
4.
int main()
5.
{
6.
double op1=0, op2=10;
7.
try
8.
{
9.
Division(op1, op2);
10.
}
11.
catch (const char* Str)
12.
{
13.
cout << "n\Bad Operator: " << Str;
14.
}
15.
return 0;
16.
}
17.
void Division(const double a, const double b)
18.
{
19.
double res;
20.
if (b == 0)
21.
throw "Division by zero not allowed";
22.
res = a / b;
23.
cout << res;
24.
}
Options:
A .  0
B .  Bad operator
C .  10
D .  None of the mentioned
Answer: Option A

We are dividing 0 and 10 in this program and we are using the throw statement in the function block.
Output:
$ g++ eal.cpp
$ a.out
0



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers