Question: I need help with my C + + program. - I need to write a function divide that takes two integers as parameters and returns

I need help with my C++ program.
-I need to write a functiondividethat takes two integers as parameters and returns the result of their division. If the divisor is zero, throw an exception. Use the starter code below:
double divide(int numerator, int denominator){
// Your code here
}
-i need to Write a functionaccessArraythat takes an array and an index as parameters and returns the element at that index. If the index is out of bounds, throw an exception. Use the starter code below:
int accessArray(int arr[], int size, int index){
// Your code here
}
- I need to Write a functionnestedFunctionthat throws aCustomException. In another functionouterFunction, callnestedFunctionand catch the exception, then rethrow it. Use the starter code below:
void nestedFunction(){
// Your code here }
void outerFunction(){
// Your code here with nestedFunction();
}
}
Example outputs of the functions:
Caught exception in outerFunction: Error in nestedFunction Caught rethrown exception in main: Error in nestedFunction
Enter numerator: 10
Enter denominator: 0
Error: Division by zero is not allowed.
Enter array size: 5
Enter index to access: 10
Error: Index out of bounds.

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 Programming Questions!