C++ | Exception Handling | Question 11

What happens in C++ when an exception is thrown and not caught anywhere like following program.

filter_none

edit
close

play_arrow

link
brightness_4
code

#include <iostream>
using namespace std;
  
int fun() throw (int)
{
    throw 10;
}
  
int main() {
  
  fun();
  
  return 0;
}
  

chevron_right


(A) Compiler error
(B) Abnormal program termination
(C) Program doesn’t print anything and terminates normally
(D) None of the above


Answer: (B)

Explanation: When an exception is thrown and not caught, the program terminates abnormally.

Quiz of this Question

Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.

My Personal Notes arrow_drop_up