C++ How to Program (10th Edition)
10th Edition
ISBN: 9780134448237
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 17, Problem 17.30E
Program Plan Intro
- Include header files required
- Declare and define a function test().
- Start a try block.
- Accept a choice to enter a number or a character.
- If 1 is entered as choice, a number is accepted and checked if it’s a negative number.
- If a negative number then and throw an exception with integer parameter, which is caught from main function.
- If 2 is entered as choice, a character is accepted and checked if it is zero. If Zero, then throw an exception with character parameter, which is caught from inside function.
- Write a catch block with character parameter which will display exception with character.
- End of function.
- Start a main function
- Start a try block which will call a function "test()", that will throw an exception.
- Write a catch block with integer parameter which will display exception called.
- Return and exit main.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
find a counterexample for the statement,
what is ignore() function ?
What is wrong in the following function?
Chapter 17 Solutions
C++ How to Program (10th Edition)
Ch. 17 - (Exceptional Conditions) List various exceptional...Ch. 17 - (Catch Parameter) Under what circumstances would...Ch. 17 - (throw Statement) A program contains the statement...Ch. 17 - (Exception Handling vs. Other Schemes) Compare and...Ch. 17 - Prob. 17.19ECh. 17 - Prob. 17.20ECh. 17 - Prob. 17.21ECh. 17 - (Catching Derived-Class Exceptions) Use...Ch. 17 - (Throwing the Result of a Conditional Expression)...Ch. 17 - Prob. 17.24E
Knowledge Booster
Similar questions
- What is the output of the following c++ codes?arrow_forwardExplain the difference between Program Counter(PC) and Exception Program Counter in your own words with appropriate examplesarrow_forwardwhat does this mean/do in Python? when loading in a text file for i in f:line = i.strip().split(",")arrow_forward
- - Write the Matlab commands to do the following: 1-Define variable Q, which has 61 equally spaced points between 0 and 30.arrow_forwardIn 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.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning