Question: 12.5 Program: Divide by Zero (C++) This program will test exception handling during division. The user will enter 2 numbers and attempt to divide (in

12.5 Program: Divide by Zero (C++)

This program will test exception handling during division.

The user will enter 2 numbers and attempt to divide (in a try block) the 1st number by the 2nd number.

The program will provide for 2 different catch statements:

Division by zero - denominator is zero

Division results in a negative number

The user should be prompted with Enter 2 numbers:

For input of 7 and 0 the output should be Exception: Division by zero

For input of 7 and 2 the output should be a/b = 3.5

For input of 7 and -2 the output should be Exception: Division is negative

L

Lab Submission

12.5.1: Program: Divide by Zero

Instructions

Deliverables

DivideByZero.cpp

We will expect the above file(s) to be submitted

Compile command

g++ DivideByZero.cpp -Wall -o a.out

We will use this command to compile your code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!