Write a program that will input a value, a number of roots, and the precision to which the roots should be calculated. Your program should then calculate the given number of roots (i.e. if you are calculating four roots, calculate the square, cube, fourth, and fifth roots) to the given precision and display the results on the screen. Your program should also be able to handle special cases such as negative input values, as well as any other cases you may encounter (there are a couple in particular).
An example executable is available here for you to try out for yourself.
The catch is that your program must calculate those roots using only code that you have written—you can’t use any functions from the cmath library—in fact, the only library you can use is iostream.
There are many ways to approach this problem, but there is a type of approach that is much better than the others.Toggle Answer