Answer:8. Consider the following code segment:
void divide(int x, int y)
{
try
{
if(y==0)
throw y;
else
cout<<endl<<"Division result is: " <<x/y<<endl;
}
catch(int)
{
throw;
cout<<endl<<"Caught Divide by zero error inside function";
}
}
int main()
{
try
{
divide(20,0);
}
catch(int)
{
cout<<endl<<"Caught Divide by zero error inside main";
}
return 0;
}
What will be the output of the above code?
Options
a) Caught Divide by zero error inside main
b) Caught Divide by zero error inside main
Caught Divide by zero error inside function
c) Caught Divide by zero error inside function
d) None of the above
Answer : a) Caught Divide by zero error inside main