1.

What is the output of this program?
#include <iostream>
#include <string>
using namespace std;
int main ()
{
int n = 5;
string str = "Exception Caught: Wrong number used";
try
{
if ( n == 1 )
{
throw 10;
}
if ( n == 2 )
{
throw 3.5f;
}
if ( n != 1 || n != 2 )
{
throw str;
}
}
catch (int p)
{
cout << "Exception value is: " << p << endl;
}
catch (float q)
{
cout << "Exception value is: " << q << endl;
}
catch (string str)
{
cout << str << endl;
}
return 0;
}

A. Exception value is: 10
B. Compilation Error
C. Exception value is: 3.5
D. Exception Caught: Wrong number used
E. None of these
Answer» E. None of these


Discussion

No Comment Found

Related MCQs