Question
#include <iostream>
using namespace std;
void PrintSequence(int StopNum)
{
int Num;
Num = 1;
while (true)
{
if (Num >= StopNum)
throw Num;
cout << Num;
Num++;
}
}
int main(void)
{
try
{
PrintSequence(20);
}
catch(int ExNum)
{
cout << "Caught an exception with value: " << ExNum;
}
return 0;
}
a.
compile time error
b.
prints first 19 numbers
c.
prints first 19 numbers and throws exception at 20
d.
none of the mentioned
Posted under Object Oriented Programming Using C++
Engage with the Community - Add Your Comment
Confused About the Answer? Ask for Details Here.
Know the Explanation? Add it Here.
Q. What is the output of this program?
Similar Questions
Discover Related MCQs
Q. What will happen when the exception is not caught in the program?
View solution
Q. Which key word is used to check exception in the block of code?
View solution
Q. To where does the program control transfers when exception is arised?
View solution
Q. Which keyword is used to access the variable in namespace?
View solution
Q. What is the general syntax for accessing the namespace variable?
View solution
Q. What is the use of Namespace?
View solution
Q. Identify the correct statement.
View solution
Q. Which operator is used to signify the namespace?
View solution
Suggested Topics
Are you eager to expand your knowledge beyond Object Oriented Programming Using C++? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!