Question
1.
#include
2.
using namespace std;
3.
int main()
4.
{
5.
double a = 10, b = 5, res;
6.
char Operator = '/';
7.
try
8.
{
9.
if (b == 0)
10.
throw "Division by zero not allowed";
11.
res = a / b;
12.
cout
What is the output of this program?
1.
#include
2.
using namespace std;
3.
int main()
4.
{
5.
double a = 10, b = 5, res;
6.
char Operator = '/';
7.
try
8.
{
9.
if (b == 0)
10.
throw "Division by zero not allowed";
11.
res = a / b;
12.
cout
Answer: Option D
Was this answer helpful ?
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.
Output:
$ g++ gex.cpp
$ a.out
10 / 5 =2
Was this answer helpful ?
Submit Solution