-
What is the output of this program?
#include
using namespace std;
void SequenceFun(int StopNumber)
{
int N;
N = 1;
while (true)
{
if (N >= StopNumber)
throw N;
cout << N;
N++;
}
}
int main(void)
{
try
{
SequenceFun(5);
}
catch(int ExNumber)
{
cout <cout << "Exception occur with value: " << ExNumber;
}
return 0;
}
-
- Runtime Error
- Compilation Error
- prints first 4 numbers
- prints first 4 numbers and throws exception at 5
- None of these
Correct Option: D
In this program, we are printing upto 4 numbers and when executing the 5, we are raising a exception.