Vidyalelo
C++ Programming · Q245

C++ miscellaneous

Programming · C++ Programming · question 245

Q245

What will be the output of the following C++ code? #include using namespace std; void PrintSequence(int StopNum) int Num; Num = 1; while (true) if (Num >= StopNum) throw Num; cout << Num << endl; Num++; int main(void) try PrintSequence(2); catch(int ExNum) cout << "exception: " << ExNum << endl; return 0;

A.
1
B.
exception: 2
C.
1
exception: 2
Answer
D.
exception: 4

Answer: Option C

Solution

Answer: Option C
No explanation is given for this question Let's Discuss on Board