EBK C HOW TO PROGRAM
EBK C HOW TO PROGRAM
8th Edition
ISBN: 9780133964639
Author: Deitel
Publisher: PEARSON CUSTOM PUB.(CONSIGNMENT)
bartleby

Concept explainers

Question
Book Icon
Chapter 22, Problem 22.15E
Program Plan Intro

To list various type of exceptional conditions that have occurred throughout this text and how the program would handle the exceptions.

Expert Solution & Answer
Check Mark

Explanation of Solution

    S. No.ExceptionException Handling
    1.Division by ZeroThis exception is handled by defining a catch handler.

    Using a try block, the denominator can be verified. If it is zero, the program throws an exception.

    The catch block catches the exception and informs the user.

    2.Out-of-range array subscriptsA catch- handler can handle this exception. The code can be placed in a try block. If an error occurs, the exception can be caught by the catch block.
    3.Arithmetic flowThe code is place in the try block.

    If any value exceeds the maximum value permitted, the exception can be thrown. The catch block will catch this exception and print this.

    4.Arithmetic underflowSimilarly, if any value is lesser than the permitted minimum value, the exception can be thrown by the try block and can be caught by catch block.
    5.Invalid function parameters This exception indicates the invalid argument(s) to any function from which it is thrown. This too is handled by using catch block.
    6.Unsuccessful memory location This exception is generated when the ‘new’ operator fails to allocate a memory. To handle this exception, place the code in a try block and catch the exception when error is recorded and validated.

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
(Throwing Exceptions from a catch) Suppose a program throws an exception and the appropriate exception handler begins executing. Now suppose that the exception handler itself throwsthe same exception. Does this create infinite recursion? Write a program to check your observation.
(Constructors Throwing Exceptions) Write a program that shows a constructor passing information about constructor failure to an exception handler after a try block
[Access Control Policy]: A computer system usually implements the exception handling mechanism. Like the interrupt handling mechanism, the original program flow will be stopped until the exception is handled. For example, when a program is calculating c=a/b, and for some reason b was set to 0, the program will encounter the "Division by Zero" exception. The control will be given to the exception handler, and the recovery action could be "report only", "return to the next instruction", "purge the program", etc., based on the severity of the problem. From the abov information, we can conclude: A computer system can integrate both Discretionary Access Control (DAC) and Mandatory Access Control (MAC) security policies An administrator can inhibit the exception handling The exception handling mechanism is like the Mandatory Access Control security policy, no matter which user caused the exception (even the administrator), the program should be stopped, and the control should be given to the…
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education