1. ## Sqrt() Function

hi everyone...just wanna say thanks for everyone that help me so far since i'm very new to C.

the problem asked to write a C function name root4() that returns the fourth root of the argument passed to it. in writing root4() use the sqrt() library function.

#include<stdio.h>
#include<math.h>
double sqrt(double num);//function type

int main()
{
double num,total;
total = sqrt(4.0 + 7*3);
printf("\nthe 4th root is %lf", total);
return 0;
}
output:
the 4th root is 5.000000Press any key to continue 2. >>total = sqrt(4.0 + 7*3);
This is

7*3 = 21
4 + 21 = 25
sqrt(25) = 5

Obvious typo fixed (thanks ronin) 3. 4+21 = 5? Not in my math class. double root4(double argument){ return sqrt(sqrt(argument)); } 4. What about root( double n, double number ) { return pow( number, 1.0 / n ); }

Edit:
Oops. Forgot to use sqrt. 5. For a bit of math to explain the double square root above, incase you need it...

sqr(x)=x^(1/2)
fourth root (x)=x^(1/4)

((x^n)^m)=x^(n*m)

so...

sqr(sqr(x))=(x^(1/2))^(1/2)=x^(1/4)=fourth root (x) Popular pages Recent additions 