Question

What is exception handling ? What is the sequence of events when an exception occurs ? Write a C++ program that uses exception handling to handle the errors caused, when a number is divided by zero.

31 Jul 2018
Answer :
Word Count : 548

Exception handling is a mechanism in programming languages, including C++, that allows the identification and management of runtime errors in a more controlled manner. In C++, exception handling is done using three keywords: `try`, `catch`, and `throw`.

1. Try Block:
   - The code that might throw an exception is enclosed within a `try` block. It is the section of code where you anticipate potential errors.

2. Throw Statement:
   - If an error occurs in the `try` block, you can use the `throw` statement to raise an exception. This is typically done with an object that represents the error.

3. Catch Blocks:
   - The `catch` block is used to catch and handle the exceptions thrown in the `try` block. Each `catch` block is associated with a specific type of exception. If an exception of that type is thrown, the corresponding `catch` block is executed.

4. Exception Handling Hierarchy:
   - C++ supports a hierarchy of exception classes. You

_________ __________ ___ ____ ___ ______ ________ ____ _____ ___ _____ _____.
_______ ______ _____ _____ __________ _____ ____ _______ ____ _________ _______.
______ ___ _________ _________ _______ _____.
_______ _____ ____ ___ _______ _____ __________.
___ ______ _______ ___ _______ _______ _________ __________.
___ _________ ________ ________ ____ ______ ________.
______ __________ ____ _________ _________ ____ _________ _____ __________ ______.
____ ___ _________ ______ ____ _____ ___ _________.
______ _______ ________ _____ _______ _________ ___ _____.
___ __________ ___ _____ ________ ______.
______ ___ ________ ______ __________ _______ ____ ____.
_____ _____ ________ _____ ___ _______.
_______ ________ _______ ______ ________ ___ ____ _________.
________ ________ _____ ___ __________ __________ ____ ____ __________.
_____ __________ ___ ____ ______ ______ _________ ____ ________ __________ _______.
_____ ________ ______ _____ ____ _______ _______ _______ ____ __________.
_________ ___ _______ ____ ____ _____ _________ _____.
_________ _____ _______ __________ ___ __________.
______ __________ _______ ____ _______ ________ ________ ___ ______.
______ ____ ______ _______ ______ ______ ____.
_______ _______ _____ ___ _________ ________ ____ __________ ____ ____ ________ ____.
_______ _________ ________ __________ ______.
__________ _____ _____ ____ __________ _________ __________ ______ _______.
________ _______ _________ __________ __________ ________.
__________ ___ _______ __________ ____ _____ _______ ___ _________ _____ ________ ___.
_____ ________ __________ ___ __________ ______ __________ _________ ___.
_____ ___ _______ _____ _______ ________ ____ ___ _____ ______ __________.
____ ___ _______ _________ ___ ______ _____ __________ _________ _____.
______ ___ __________ ______ ________.
________ ______ _____ ____ ________ _______ ______ _________.
__________ ___ ____ ______ _________ __________ ______ _________.
_____ ________ _____ ______ ____ __________ ______ ______ ________ _________ ______ _________.
_________ ____ ____ ________ ____ _________ _________ ________ _______ _______.
________ ____ ________ _____ _____ __________ ________ ____ _________ ________.
__________ _________ __________ ___ ____ __________ __________ ___ _____.
____ _________ _________ ______ ___ ________ ________ _____ ___ ____ ____.
________ ________ _______ _________ ____ ____ _________ ____.
_____ _________ _______ _______ __________ ___ _____ _____ _____ __________.
___ ___ _______ __________ _________.
__________ _______ _____ ______ ____ _______.
______ ____ ___ ____ _____ ________ _________.
_____ _______ ___ __________ ___ _______ _________ ___ _________ ____ ______.
____ ______ ____ _______ __________ ________ ______ __________ ___ ________ _______ _____.
_________ ____ ____ ________ ___ _________ ______ __________ ______ ________ ______ ________.
______.
IGNOU ACADEMY
Your IGNOU journey, made easier.
  • Solved Assignments
  • Study Notes
  • Guess Papers
  • Question Papers
Skip in 10
Top
📞
Call Support Instant phone assistance IGNOU BCS 31 2016 - What is exception handling ? What is the sequence of events when an ex | IGNOU Academy
→
🟢
WhatsApp Chat Fast live messaging
→
Email Us Business enquiries & support
→