Problem 1:

To access a subtring of a string str, you can use the function defined by the following function prototype:

stringsubstr(size_tstartIndex, size_t length);

Save your time - order a paper!

Get your paper written from scratch within the tight deadline. Our service is a reliable solution to all your troubles. Place an order on any task and we will take care of it. You won’t have to worry about the quality and deadlines

Order Paper Now

However if startIndex>str.size(), this substr function will cause an out_of_range exception and terminate the program.

Write an StrExcept exception class that inherits from the base exception class out_of_range by defining its own constructor and a print() method outputting a custom error message to the user.

Then, in the main method, write a program that asks the user to enter a string before asking him/her to enter the start index of the substring and its length.

This program should throw StrExcept if the start index is larger than the size of the string and handle this exception by surrounding it by try-catch block.

Note that out_of_range class would require you to include stdexcept library.


Write a recursive version of the binary search algorithm.

Function prototype:intbSearch(constint a[],int lo, inthi,intx)

Where lo and hi are the indexes of the first and last element of the binary search.

Note: You can assume that the items of the searched array to test in your main method are sorted/

Do you need a similar assignment done for you from scratch? We have qualified writers to help you. We assure you an A+ quality paper that is free from plagiarism. Order now for an Amazing Discount!
Use Discount Code "Newclient" for a 15% Discount!

NB: We do not resell papers. Upon ordering, we do an original paper exclusively for you.