D
Dildo Boy
I am trying to write a program which asks the user to enter a number
in the interval [1,2], the program then gives the natural logarithm of
that number, using the series for log(x+1)...
Here is what I have so far and have been tinkering with it for EVER!
any help would be greatly appreciated, thanks guys...
#include <stdio.h>
#include <math.h>
int main() {
int i,n;
double x;
float sum, term;
printf("Enter a number in the interval [1,2]> ");
scanf("%d", &n);
sum = 0;
i = 0;
do {
i = i+1;
x = (double) i;
term = pow(x, i)/i;
if(i % 2 == 1)
sum = sum + term;
else
sum = sum - term;
} while(i <= n);
printf("The answer is %lf\n",sum);
}
in the interval [1,2], the program then gives the natural logarithm of
that number, using the series for log(x+1)...
Here is what I have so far and have been tinkering with it for EVER!
any help would be greatly appreciated, thanks guys...
#include <stdio.h>
#include <math.h>
int main() {
int i,n;
double x;
float sum, term;
printf("Enter a number in the interval [1,2]> ");
scanf("%d", &n);
sum = 0;
i = 0;
do {
i = i+1;
x = (double) i;
term = pow(x, i)/i;
if(i % 2 == 1)
sum = sum + term;
else
sum = sum - term;
} while(i <= n);
printf("The answer is %lf\n",sum);
}