I tried to use this code to solve the question in the picture but I can't solve it, I'd be happy to help.
how can I fix the code that works for the question in the picture? thanks.
#include
void main() {
int n, i;
double sum, x, last;
do {
printf("Enter an positive number: ");
scanf("%d", & n);
} while (n<0);
printf("Please enter x: ");
scanf("%lf", & x);
sum = last = x;
for (i = 1; i<= n; i++) {
last = last * (-1) * ((x * x) / ((2 * i - 1) * (2 * i)));
sum = sum + last;
}
printf("S = %lf\n", sum);
}