Just started learning about functions and attempted a problem from a textbook; "Write a function cube_root that receives a double argument and calculates and returns an approximate cube root for it. You should also write a main program that allows you to test your function"
I tried, and subsequently failed. Any help as to where I went wrong?
1) you should pass variable to scanf() by pointer (why do you use scanf()?)
Like that: scanf("%d", &input);
2) %d is for integers. I don't remember, what is used for doubles, but you can use %f for floats. printf("The resulting cube root is: %f", cbrt(input));
3) Your cbrt function ist' working properly. Look at your loop: for now it is equivalent to