-
What is the output of this program?
#include <iostream>
using namespace std;
int main()
{
int num = -2;
try
{
if (num < 0)
{
throw num;
}
else
{
cout<< num;
}
}
catch (int num )
{
cout << "Exception occurred: Thrown value is " << num << endl;
}
return 0;
}
-
- Compilation Error
- Runtime Error
- -2
- Exception occurred: Thrown value is -2
- None of these
Correct Option: D
As the given value is -2 and according to the condition, We are arising an exception.