Answer the question
In order to leave comments, you need to log in
Should it be?
Hello.
A simple task, but somehow something ..
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
double x;
double resultForLN = 0, resultForSum = 0;
printf("Enter X : ");
scanf("%g",&x);
resultForLN = log( (1.0 + x) / (1.0 - x) );
printf("%g",resultForLN); // Левый результат
for (int k = 1; k < 100; k++)
resultForSum += pow(x, (2.0 * k - 1.0)) / (2.0 * k - 1.0);
printf("\n%g",resultForSum * 2.0); // Правый результат
}
Answer the question
In order to leave comments, you need to log in
You have an error in scanf. %lg
works too - at least on MinGW.
Little is known, but scanf has a slightly different substitution format than printf.
Forget about float, always use double by default.
You calculate x^197 / 197 at the end. Even with x = 2, this will not fit into the float.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question