I'm making a calculator and have so far made addition, subtraction, division, multiplication, raise to the power, and fractorial, but I want to make the option of finding the roots of numbers like: fourth root of 16 which is 2 and I'd like to write a formula that allows me to take any root of any number like root 78.342 of 2.098E23. Does anyone have any idea on how to code this? I tried to write the function:
Your parameters for root make little sense - the only components needed for the calculation of a root is the radicand and the degree - no "answers", no "firsts" and no "seconds" are involved.
Also, float is bad news. With only 32 bits to work with, it's terribly inaccurate. Use double (which has 64 bits) whenever feasible.
There's a much easier method of calculating a root: