C++ How to Program (10th Edition)
C++ How to Program (10th Edition)
10th Edition
ISBN: 9780134448237
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 17, Problem 17.26E
Program Plan Intro

Program Plan:

  • Include header files
  • Start main function
    • Make a menu to ask from user which type of exception it want to check and throw.
    • Accept the choice in variable "x".
    • If "x" is entered 1 then exception is thrown with integer value.
    • If "x" is entered 2 then exception is thrown with float value.
    • If "x" is entered 3 then exception is thrown with character value.
    • If "x" is entered 4 then exception is thrown with string value.
    • else no exception is thrown
    • We can write multiple catch statements to catch all the exception types, such as
      • catch(int i){}
        catch(float f){}
        catch(char c){}
        catch(char *c){}
        But we have to catch all exception using single catch so we are using catch(...) exception handler.
  • Return and exit.

Blurred answer
Students have asked these similar questions
In a few well-written paragraphs, discuss the use of exceptions and exception handling in programming. Your discussion should include definitions for exception, exception handler, throw signal, and catch process. Discuss why exceptions are helpful for handling runtime errors, such as division by zero.
Give the names of the three techniques for dealing with exceptions.
The C++ exception class includes the function _______________.
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
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning