SlideShare a Scribd company logo
1 of 22
A Presentation 0f Advance Pr0gramming Language
Implicit & Explicit Sequence Control
and
Exception Handling
Master of Technology
In
Computer Science &Engineering
Submitted T0 Submitted By
Miss. Manshi Gupta Vikash MainanwaI
Control Structure
Sequence Control Structure
Implicit
Explicit
Exception
Exception Handling
Bibliography
CONTENTS
Control structures: the basic framework
within which operations and data are
combined into programs.
 Sequence control
 data control
1.Control Structure
the control of the order of execution of the operations
(Primitive, user defined).
1.1 Sequence control
1.2 Data control
the control of the transmission of data among the
subprograms of a program.
Implicit sequence control: (default)
defined by the language .
Explicit sequence control: defined by the
programmer.
Types of sequence control
Example of Explicit Sequence control
Describe Exception
An exception is an erroneous situation that occurs during
program execution.
When an exception occurs in an application, the system
throws an error.
The error is handled through the process of exception
handling.
Types of Error
There are three types of errors that can occur in the application:
Syntax errors: Occurs when statements are not constructed
properly, keywords are misspelled, or punctuation is omitted.
Run-time errors: Occurs when an application attempts to perform
an operation, which is not allowed at runtime.
Logical errors: Occurs when an application compiles and runs
properly but does not produce the expected results.
Let us understand the various types of errors in detail.
Syntax Error
class Errors
{
Console.WriteLine(“Enjoy Errors”)
}
Semicolon is missing from Console.WriteLine statement
Run Time Error
class Errors
{
int Num1=0;
int Num2=20;
int Num3;
Num3=Num2/Num1;
Console.WriteLine(“The Result is {0}”,
Num3);
}
Division by zero has taken place
Logical Error
class Errors
{
int Num1=10;
int Num2=2;
int Num3;
Num3=Num2/Num1;
Console.WriteLine(“The Result is
{0}”, Num3);
}
Expected result = 5
Present result = 0.2
There are many exception classes which are
directly or indirectly derived from the
System.Exception class. Some of these
classes are:
System.ApplicationException class
System.SystemException class
Exception Classes
—The hierarchy of the exception classes is displayed in the following
figure.
Exception Classes
System. Exception
System.ApplicationException
System.SystemException
Handling Exception
In exception handling, the application is divided into blocks of code.
A block that shows the probability of raising an error contains one or
more exception handlers.
The exception handlers follow a control structure and a uniform way of
handling the system level and application level errors.
The blocks for exception-handling can be implemented using the
following keywords:
try
catch
finally
Let us look at each of these keywords in detail.
Exception Handling Control Flow
Try Block
The try block:
The try block guards statements that may throw an exception. Following is
the syntax of try block statement:
try
{
//statements that may cause an exception
}
The try block governs statements that are enclosed within it and defines
the scope of the exception-handlers associated with it.
A try block must have at least one catch block.
Catch Block
The catch block:
The catch statement of the catch block takes an object of the exception
class as a parameter, which refers to the raised exception.
You can associate an exception-handler with the try block by providing
one or more catch handlers, immediately after the try block:
try
{
//statements that may cause an exception
}
catch (…)
{
//error handling code
}
Finally Block
The finally block:
The finally block is used to execute a given set of
statements, whether an exception is thrown or not thrown:
try
{
//statements that may cause an exception
}
catch (…)
{
//error handling code
}
finally
{
//statements to be executed
}
Example of Exception Handling
Bibliography
• Programming Language Terrance W.Pratt
• —www.dotnetperls.com/exception
• —msdn.microsoft.com/en-
us/library/ms173160.aspx
 —www.tutorialspoint.com/csharp/csharp_exception_handlin
g.
• The complete reference C# 4.0 Tata McGraw-Hill
Implicit and explicit sequence control with exception handling
Implicit and explicit sequence control with exception handling

More Related Content

What's hot

compiler ppt on symbol table
 compiler ppt on symbol table compiler ppt on symbol table
compiler ppt on symbol tablenadarmispapaulraj
 
Organization and team structures
Organization and team structuresOrganization and team structures
Organization and team structuresNur Islam
 
Cost estimation using cocomo model
Cost estimation using cocomo modelCost estimation using cocomo model
Cost estimation using cocomo modelNitesh Bichwani
 
Architectural modeling chapter 5 of omd
Architectural modeling chapter 5 of omdArchitectural modeling chapter 5 of omd
Architectural modeling chapter 5 of omdjayashri kolekar
 
System Programming Unit II
System Programming Unit IISystem Programming Unit II
System Programming Unit IIManoj Patil
 
COCOMO Model in software project management
COCOMO Model in software project managementCOCOMO Model in software project management
COCOMO Model in software project managementSyed Hassan Ali
 
Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & LanguagesGaditek
 
Type checking in compiler design
Type checking in compiler designType checking in compiler design
Type checking in compiler designSudip Singh
 
Designing Techniques in Software Engineering
Designing Techniques in Software EngineeringDesigning Techniques in Software Engineering
Designing Techniques in Software Engineeringkirupasuchi1996
 
System Programing Unit 1
System Programing Unit 1System Programing Unit 1
System Programing Unit 1Manoj Patil
 
Modules and modularization criteria
Modules and modularization criteriaModules and modularization criteria
Modules and modularization criteriaUmaselvi_R
 
Operators in java presentation
Operators in java presentationOperators in java presentation
Operators in java presentationkunal kishore
 

What's hot (20)

compiler ppt on symbol table
 compiler ppt on symbol table compiler ppt on symbol table
compiler ppt on symbol table
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
 
Organization and team structures
Organization and team structuresOrganization and team structures
Organization and team structures
 
Cost estimation using cocomo model
Cost estimation using cocomo modelCost estimation using cocomo model
Cost estimation using cocomo model
 
Unit 2
Unit 2Unit 2
Unit 2
 
Architectural modeling chapter 5 of omd
Architectural modeling chapter 5 of omdArchitectural modeling chapter 5 of omd
Architectural modeling chapter 5 of omd
 
Two pass Assembler
Two pass AssemblerTwo pass Assembler
Two pass Assembler
 
System Programming Unit II
System Programming Unit IISystem Programming Unit II
System Programming Unit II
 
COCOMO Model in software project management
COCOMO Model in software project managementCOCOMO Model in software project management
COCOMO Model in software project management
 
Phases of Compiler
Phases of CompilerPhases of Compiler
Phases of Compiler
 
Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & Languages
 
Type checking in compiler design
Type checking in compiler designType checking in compiler design
Type checking in compiler design
 
Interactive debugging system
Interactive debugging systemInteractive debugging system
Interactive debugging system
 
Designing Techniques in Software Engineering
Designing Techniques in Software EngineeringDesigning Techniques in Software Engineering
Designing Techniques in Software Engineering
 
System Programing Unit 1
System Programing Unit 1System Programing Unit 1
System Programing Unit 1
 
Translators(Compiler, Assembler) and interpreter
Translators(Compiler, Assembler) and interpreterTranslators(Compiler, Assembler) and interpreter
Translators(Compiler, Assembler) and interpreter
 
State chart diagram
State chart diagramState chart diagram
State chart diagram
 
Modules and modularization criteria
Modules and modularization criteriaModules and modularization criteria
Modules and modularization criteria
 
Ch 4 linker loader
Ch 4 linker loaderCh 4 linker loader
Ch 4 linker loader
 
Operators in java presentation
Operators in java presentationOperators in java presentation
Operators in java presentation
 

Similar to Implicit and explicit sequence control with exception handling

Introduction of exception in vb.net
Introduction of exception in vb.netIntroduction of exception in vb.net
Introduction of exception in vb.netsuraj pandey
 
Java -Exception handlingunit-iv
Java -Exception handlingunit-ivJava -Exception handlingunit-iv
Java -Exception handlingunit-ivRubaNagarajan
 
UNIT-3.pptx Exception Handling and Multithreading
UNIT-3.pptx Exception Handling and MultithreadingUNIT-3.pptx Exception Handling and Multithreading
UNIT-3.pptx Exception Handling and MultithreadingSakkaravarthiS1
 
Md07 exceptions&assertion
Md07 exceptions&assertionMd07 exceptions&assertion
Md07 exceptions&assertionRakesh Madugula
 
130410107010 exception handling
130410107010 exception handling130410107010 exception handling
130410107010 exception handlingHemant Chetwani
 
7.error management and exception handling
7.error management and exception handling7.error management and exception handling
7.error management and exception handlingDeepak Sharma
 
Chapter 8 agent-oriented software engineering ch8-prometheus research methodo...
Chapter 8 agent-oriented software engineering ch8-prometheus research methodo...Chapter 8 agent-oriented software engineering ch8-prometheus research methodo...
Chapter 8 agent-oriented software engineering ch8-prometheus research methodo...farshad33
 
Software testing and_quality_assurance_powerpoint_presentation
Software testing and_quality_assurance_powerpoint_presentationSoftware testing and_quality_assurance_powerpoint_presentation
Software testing and_quality_assurance_powerpoint_presentationvigneshasromio
 
Exception handling
Exception handlingException handling
Exception handlingRaja Sekhar
 
Chapter 8 - Software Testing.ppt
Chapter 8 - Software Testing.pptChapter 8 - Software Testing.ppt
Chapter 8 - Software Testing.pptGentaSahuri2
 
Week7 exception handling
Week7 exception handlingWeek7 exception handling
Week7 exception handlingAlpesh Oza
 
Week7 exception handling
Week7 exception handlingWeek7 exception handling
Week7 exception handlingAlpesh Oza
 
Week7 exception handling
Week7 exception handlingWeek7 exception handling
Week7 exception handlingAlpesh Oza
 
Integration testing
Integration testingIntegration testing
Integration testingqueen jemila
 
Software engg. pressman_ch-8
Software engg. pressman_ch-8Software engg. pressman_ch-8
Software engg. pressman_ch-8Dhairya Joshi
 

Similar to Implicit and explicit sequence control with exception handling (20)

Introduction of exception in vb.net
Introduction of exception in vb.netIntroduction of exception in vb.net
Introduction of exception in vb.net
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
 
Java -Exception handlingunit-iv
Java -Exception handlingunit-ivJava -Exception handlingunit-iv
Java -Exception handlingunit-iv
 
Ch20
Ch20Ch20
Ch20
 
UNIT-3.pptx Exception Handling and Multithreading
UNIT-3.pptx Exception Handling and MultithreadingUNIT-3.pptx Exception Handling and Multithreading
UNIT-3.pptx Exception Handling and Multithreading
 
Md07 exceptions&assertion
Md07 exceptions&assertionMd07 exceptions&assertion
Md07 exceptions&assertion
 
130410107010 exception handling
130410107010 exception handling130410107010 exception handling
130410107010 exception handling
 
7.error management and exception handling
7.error management and exception handling7.error management and exception handling
7.error management and exception handling
 
Chapter 8 agent-oriented software engineering ch8-prometheus research methodo...
Chapter 8 agent-oriented software engineering ch8-prometheus research methodo...Chapter 8 agent-oriented software engineering ch8-prometheus research methodo...
Chapter 8 agent-oriented software engineering ch8-prometheus research methodo...
 
Testing
TestingTesting
Testing
 
Presentation1
Presentation1Presentation1
Presentation1
 
Exception Handling in Java
Exception Handling in JavaException Handling in Java
Exception Handling in Java
 
Software testing and_quality_assurance_powerpoint_presentation
Software testing and_quality_assurance_powerpoint_presentationSoftware testing and_quality_assurance_powerpoint_presentation
Software testing and_quality_assurance_powerpoint_presentation
 
Exception handling
Exception handlingException handling
Exception handling
 
Chapter 8 - Software Testing.ppt
Chapter 8 - Software Testing.pptChapter 8 - Software Testing.ppt
Chapter 8 - Software Testing.ppt
 
Week7 exception handling
Week7 exception handlingWeek7 exception handling
Week7 exception handling
 
Week7 exception handling
Week7 exception handlingWeek7 exception handling
Week7 exception handling
 
Week7 exception handling
Week7 exception handlingWeek7 exception handling
Week7 exception handling
 
Integration testing
Integration testingIntegration testing
Integration testing
 
Software engg. pressman_ch-8
Software engg. pressman_ch-8Software engg. pressman_ch-8
Software engg. pressman_ch-8
 

More from VIKASH MAINANWAL

Gas Management System by Vikash Mainanwal
Gas Management System by Vikash MainanwalGas Management System by Vikash Mainanwal
Gas Management System by Vikash MainanwalVIKASH MAINANWAL
 
Virus Attack & firewall by vikash mainanwal
Virus Attack & firewall by vikash mainanwalVirus Attack & firewall by vikash mainanwal
Virus Attack & firewall by vikash mainanwalVIKASH MAINANWAL
 
MANETS Routing By Vikash Maianwal
MANETS Routing By Vikash MaianwalMANETS Routing By Vikash Maianwal
MANETS Routing By Vikash MaianwalVIKASH MAINANWAL
 
Asynchronous Message Passing
Asynchronous Message PassingAsynchronous Message Passing
Asynchronous Message PassingVIKASH MAINANWAL
 

More from VIKASH MAINANWAL (6)

Remote Procedure Call
Remote Procedure CallRemote Procedure Call
Remote Procedure Call
 
Gas Management System by Vikash Mainanwal
Gas Management System by Vikash MainanwalGas Management System by Vikash Mainanwal
Gas Management System by Vikash Mainanwal
 
Virus Attack & firewall by vikash mainanwal
Virus Attack & firewall by vikash mainanwalVirus Attack & firewall by vikash mainanwal
Virus Attack & firewall by vikash mainanwal
 
Manet By Vikas mainanwal
Manet By Vikas mainanwalManet By Vikas mainanwal
Manet By Vikas mainanwal
 
MANETS Routing By Vikash Maianwal
MANETS Routing By Vikash MaianwalMANETS Routing By Vikash Maianwal
MANETS Routing By Vikash Maianwal
 
Asynchronous Message Passing
Asynchronous Message PassingAsynchronous Message Passing
Asynchronous Message Passing
 

Recently uploaded

Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 

Recently uploaded (20)

Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 

Implicit and explicit sequence control with exception handling

  • 1. A Presentation 0f Advance Pr0gramming Language Implicit & Explicit Sequence Control and Exception Handling Master of Technology In Computer Science &Engineering Submitted T0 Submitted By Miss. Manshi Gupta Vikash MainanwaI
  • 2. Control Structure Sequence Control Structure Implicit Explicit Exception Exception Handling Bibliography CONTENTS
  • 3. Control structures: the basic framework within which operations and data are combined into programs.  Sequence control  data control 1.Control Structure
  • 4. the control of the order of execution of the operations (Primitive, user defined). 1.1 Sequence control 1.2 Data control the control of the transmission of data among the subprograms of a program.
  • 5. Implicit sequence control: (default) defined by the language . Explicit sequence control: defined by the programmer. Types of sequence control
  • 6. Example of Explicit Sequence control
  • 7. Describe Exception An exception is an erroneous situation that occurs during program execution. When an exception occurs in an application, the system throws an error. The error is handled through the process of exception handling.
  • 8. Types of Error There are three types of errors that can occur in the application: Syntax errors: Occurs when statements are not constructed properly, keywords are misspelled, or punctuation is omitted. Run-time errors: Occurs when an application attempts to perform an operation, which is not allowed at runtime. Logical errors: Occurs when an application compiles and runs properly but does not produce the expected results. Let us understand the various types of errors in detail.
  • 9. Syntax Error class Errors { Console.WriteLine(“Enjoy Errors”) } Semicolon is missing from Console.WriteLine statement
  • 10. Run Time Error class Errors { int Num1=0; int Num2=20; int Num3; Num3=Num2/Num1; Console.WriteLine(“The Result is {0}”, Num3); } Division by zero has taken place
  • 11. Logical Error class Errors { int Num1=10; int Num2=2; int Num3; Num3=Num2/Num1; Console.WriteLine(“The Result is {0}”, Num3); } Expected result = 5 Present result = 0.2
  • 12. There are many exception classes which are directly or indirectly derived from the System.Exception class. Some of these classes are: System.ApplicationException class System.SystemException class Exception Classes
  • 13. —The hierarchy of the exception classes is displayed in the following figure. Exception Classes System. Exception System.ApplicationException System.SystemException
  • 14. Handling Exception In exception handling, the application is divided into blocks of code. A block that shows the probability of raising an error contains one or more exception handlers. The exception handlers follow a control structure and a uniform way of handling the system level and application level errors. The blocks for exception-handling can be implemented using the following keywords: try catch finally Let us look at each of these keywords in detail.
  • 16. Try Block The try block: The try block guards statements that may throw an exception. Following is the syntax of try block statement: try { //statements that may cause an exception } The try block governs statements that are enclosed within it and defines the scope of the exception-handlers associated with it. A try block must have at least one catch block.
  • 17. Catch Block The catch block: The catch statement of the catch block takes an object of the exception class as a parameter, which refers to the raised exception. You can associate an exception-handler with the try block by providing one or more catch handlers, immediately after the try block: try { //statements that may cause an exception } catch (…) { //error handling code }
  • 18. Finally Block The finally block: The finally block is used to execute a given set of statements, whether an exception is thrown or not thrown: try { //statements that may cause an exception } catch (…) { //error handling code } finally { //statements to be executed }
  • 20. Bibliography • Programming Language Terrance W.Pratt • —www.dotnetperls.com/exception • —msdn.microsoft.com/en- us/library/ms173160.aspx  —www.tutorialspoint.com/csharp/csharp_exception_handlin g. • The complete reference C# 4.0 Tata McGraw-Hill