-
What is the output of this program?
#include <iostream>
using namespace std;
int main()
{
int a = 8;
try
{
if (a < 0)
throw "Positive Number Required";
cout << a << "\n\n";
}
catch(const char* Msg)
{
cout << "Error: " << Msg;
}
return 0;
}
-
- Positive Number Required
- 8
- Compilation Error
- Runtime Error
- None of these
Correct Option: B
In this program, We are checking the age of a person, If it is zero means, We will arise a exception.