Question
1.
#include
2.
#include
3.
using namespace std;
4.
int main ()
5.
{
6.
int num = 3;
7.
string str_bad = "wrong number used";
8.
try
9.
{
10.
if ( num == 1 )
11.
{
12.
throw 5;
13.
}
14.
if ( num == 2 )
15.
{
16.
throw 1.1f;
17.
}
18.
if ( num != 1 || num != 2 )
19.
{
20.
throw str_bad;
21.
}
22.
}
23.
catch (int a)
24.
{
25.
cout
What is the output of this program?
1.
#include
2.
#include
3.
using namespace std;
4.
int main ()
5.
{
6.
int num = 3;
7.
string str_bad = "wrong number used";
8.
try
9.
{
10.
if ( num == 1 )
11.
{
12.
throw 5;
13.
}
14.
if ( num == 2 )
15.
{
16.
throw 1.1f;
17.
}
18.
if ( num != 1 || num != 2 )
19.
{
20.
throw str_bad;
21.
}
22.
}
23.
catch (int a)
24.
{
25.
cout
Answer: Option C
Was this answer helpful ?
As we are giving 3 to num, It is arising an exception named
"wrong number used".
Output:
$ g++ expef.cpp
$ a.out
wrong number used
Was this answer helpful ?
Submit Solution