Sail E0 Webinar
Question


What is the output of this program?


1.
#include
2.
using namespace std;
3.
int main()
4.
{
5.
int x = -1;
6.
try
7.
{
8.
if (x < 0)
9.
{
10.
throw x;
11.
}
12.
else
13.
{
14.
cout
Options:
A .  -1
B .  0
C .  Exception occurred: Thrown value is -1
D .  error
Answer: Option C

As the given value is -1 and according to the condition, We are arising an exception.
Output:
$ g++ etae.cpp
$ a.out
Exception occurred: Thrown value is -1



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

More Questions on This Topic :

Latest Videos

Latest Test Papers