C How to Program (8th Edition)
C How to Program (8th Edition)
8th Edition
ISBN: 9780133976892
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
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
(Creating Custom Exception Class) Write a Password class that stores a password string. Passwords must contain at least seven alpha-numeric characters, with at least one letter and one digit. Also write an InvalidPasswordException class that extends Exception. The  Password constructor should throw an InvalidPasswordException, which should report an appropriate message based on a given string (e.g. if the string contains no digits, the exception should report this fact).  Use java swing to write a GUI program to prompt the user to enter a password and report an InvalidPasswordException if an invalid password is entered. Some sample screenshots are shown below:
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