Sail E0 Webinar
Question


What is the output of this program?


1.
#include
2.
using namespace std;
3.
double division(int a, int b)
4.
{
5.
if (b == 0) {
6.
throw "Division by zero condition!";
7.
}
8.
return (a / b);
9.
}
10.
int main ()
11.
{
12.
int x = 50;
13.
int y = 2;
14.
double z = 0;
15.
try {
16.
z = division(x, y);
17.
cout
Options:
A .  25
B .  20
C .  Division by zero condition!
D .  none of the mentioned
Answer: Option A

In this program, we resembling the division by using the exception handling.
Output:
$ g++ excep2.cpp
$ a.out
25



Was this answer helpful ?
Next Question

Submit Solution

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

Latest Videos

Latest Test Papers