Question
1.
#include
2.
using namespace std;
3.
void test(int x)
4.
{
5.
try
6.
{
7.
if (x > 0)
8.
throw x;
9.
else
10.
throw 'x';
11.
}
12.
catch(int x)
13.
{
14.
cout
What is the output of this program?
1.
#include
2.
using namespace std;
3.
void test(int x)
4.
{
5.
try
6.
{
7.
if (x > 0)
8.
throw x;
9.
else
10.
throw 'x';
11.
}
12.
catch(int x)
13.
{
14.
cout
Answer: Option A
Was this answer helpful ?
We are passing the integer and character and catching it by using multiple catch statement.
Output:
$ g++ gex3.cpp
$ a.out
integer:10character:x
Was this answer helpful ?
Submit Solution