Sail E0 Webinar
Question


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
Options:
A .  10
B .  2
C .  Bad Operator
D .  10 / 5 = 2
Answer: Option D

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 ?
Next Question

Submit Solution

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

More Questions on This Topic :

Latest Videos

Latest Test Papers