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
(Handling Related Exceptions) Describe a technique for handling related exceptions.
(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.
(Catching All Exceptions) Write a program that demonstrates several exception types beingcaught with the catch(...) exception handler.
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