Question
1.
#include
2.
using namespace std;
3.
void PrintSequence(int StopNum)
4.
{
5.
int Num;
6.
Num = 1;
7.
while (true) {
8.
if (Num >= StopNum)
9.
throw Num;
10.
cout
What is the output of this program?
1.
#include
2.
using namespace std;
3.
void PrintSequence(int StopNum)
4.
{
5.
int Num;
6.
Num = 1;
7.
while (true) {
8.
if (Num >= StopNum)
9.
throw Num;
10.
cout
Answer: Option C
Was this answer helpful ?
In this program, we are printing upto 19 numbers and when executing the 20, we are raising
a exception.
Output:
$ g++ excep1.cpp
$ a.out
12345678910111213141516171819Caught an exception with value: 20
Was this answer helpful ?
Submit Solution