Question
#include <iostream>
using namespace std;
int main()
{
double a = 10, b = 5, res;
char Operator = '/';
try
{
if (b == 0)
throw "Division by zero not allowed";
res = a / b;
cout << a << " / " << b << " = " << res;
}
catch(const char* Str)
{
cout << "\n Bad Operator: " << Str;
}
return 0;
}
a.
10
b.
2
c.
Bad Operator
d.
10 / 5 = 2
Posted under Object Oriented Programming Using C++
Engage with the Community - Add Your Comment
Confused About the Answer? Ask for Details Here.
Know the Explanation? Add it Here.
Q. What is the output of this program?
Similar Questions
Discover Related MCQs
Q. Pick out the correct Answer:
View solution
Q. When exceptions are used?
View solution
Q. How many parameters does the throw expression can have?
View solution
Q. Where exception are handled?
View solution
Q. Which is used to check the error in the block?
View solution
Q. How to handle the exception in constructor?
View solution
Q. What should present when throwing a object?
View solution
Q. What can go wrong in resource management on c++?
View solution
Q. When we call that resource is leaked?
View solution
Q. What kind of error can arise when there is problem in memory?
View solution
Q. What is meant by garbage collection?
View solution
Q. What are the operators available in dynamic memory allocation?
View solution
Q. Which is used to solve the memory management problem in c++?
View solution
Q. Which is used to handle the exceptions in c++?
View solution
Q. Which type of program is recommended to include in try block?
View solution
Q. Which statement is used to catch all types of exceptions?
View solution
Q. How to handle error in the destructor?
View solution
Q. What kind of exceptions are available in c++?
View solution
Q. What is meant by exception specification?
View solution
Q. Identify the correct statement about throw(type).
View solution
Suggested Topics
Are you eager to expand your knowledge beyond Object Oriented Programming Using C++? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!