This document provides an introduction to exception handling in programming. It discusses that exceptions are unusual runtime conditions, like division by zero, that a program may encounter during execution. It explains that code that could cause exceptions is placed in a try block. When an exception occurs in the try block, it is thrown using a throw statement. The catch block then handles the exception by generating user-friendly error messages. The document provides the syntax for try, throw, and catch blocks and includes an example program that catches a division by zero exception.
Overview of exception handling including TRY, THROW, CATCH syntax, and examples.
Key concepts: Exception handling as a way to manage errors, with details on TRY block, THROW expression, and CATCH block for user-friendly error messages.
Presentation of syntax for TRY and CATCH blocks, demonstrating structure and flow for handling exceptions.
Relating the concept of exception handling to a real-life scenario using a smartphone test.
Sample C++ program showcasing exception handling with division example, demonstrating TRY, THROW, and CATCH blocks.
Final remarks and conclusion about the importance of exception handling in programming.
INTRODUCTION :
Exception Handling:
It is a way of handling error which occure while executing
program.
Exception are run time unusual condition that a program may
encounter while executing..
This unusual condition includes condition such as “division by
zero”,””, or “running out of memory or disk space”.
3
4.
CONTIN….
TRY :
It isone of the block in which we write the block of
statements which causes executions at run time in
other words try block always contains problematic
statements.
4
CONTIN….
CATCH BLOCK:
It isone of the block in which we write the block of
statements which will generates user friendly error
messages in other words catch block will suppose system
error messages.
6
7.
In an programa block of code which can produce error is placed in try block
When an exception is detected in try it is thrown using throw statement
Syntax
try
{
throw exception;
}
catch(type argument)
{
}
SYNTAX
7