MCQs
None.
In this program, we allocating the memory to the arrays by using excetion handling and
we handled the exception by standard exception.
Output:
$ g++ excep5.cpp
$ a.out
Allocated successfully
As we are throwing integer to double it will raise as abnormal program after termination throw
statement.
Output:
$ g++ excep4.cpp
$ a.out
terminate called after throwing an instance of ‘int’
Aborted
As we are allocating the memory to the variables and if there is not suffcient size means, it
will throw an exception.
Output:
$ g++ excep3.cpp
$ a.out
4 Bytes allocated successfully
In this program, we resembling the division by using the exception handling.
Output:
$ g++ excep2.cpp
$ a.out
25
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
None.
As the zero marks the beginning of the positive number, it is printed as output
Output:
$ g++ excep.cpp
$ a.out
0
When a exception is arised mean, the exception is caught by handlers and then it decides
the type of exception.
The try() statement is used for exceptios in c++.