Implement a function named root_sum which receive an integer and return the result of summing all the scare roots from 1 to the number passed in. For example, if the argument is 4, then the function returns 6.15 because √4 + √3 + √2 + √1 = 6.15. It doesn't need to print (√4 + √3 + √2 + √1 = 6.15), in fact the function shouldn't print anything, just return the final value, in this case 6.15. You may assume that #include has already been included and you have access to the sqrt() function, which takes a single double or any value that can be converted to a double and returns that value's square root as a double. No error checking is necessary. Assume the user always passed in a value > 1. In c++ program
Implement a function named root_sum which receive an integer and return the result of summing all the scare roots from 1 to the number passed in.
For example, if the argument is 4, then the function returns 6.15 because √4 + √3 + √2 + √1 = 6.15.
It doesn't need to print (√4 + √3 + √2 + √1 = 6.15), in fact the function shouldn't print anything, just return the final value, in this case 6.15.
You may assume that #include <cmath> has already been included and you have access to the sqrt() function, which takes a single double or any value that can be converted to a double and returns that value's square root as a double.
No error checking is necessary. Assume the user always passed in a value > 1.
In c++ program
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images