Mail Archives: djgpp/1999/03/18/20:06:57
Paul (astralm AT home DOT com) wrote:
: Without using MATH.H's POW(x,y) function and SQRT(x) function, I must create
: a calculator that finds powers and roots.
:
: I pretty much have a decent power function, using FOR loops, but I want to
: use this function to also find roots.
:
: Here's the code:
:
: double Power (double num1, double num2);
: {
: int i;
:
: for (i = 1; i <= num2; i++)
: num1 *= num1;
:
: return num1;
: }
Hmm, I thought 2^0 = 1 != 2.
Anyway for the (square) root of y (i. e. SQRT(y)) you might consider
that you need to find the x with the property Power(x, 2) == y.
Shostakovich, Symphony No. 5,
MartinS
- Raw text -