Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

What\'s wrong with this? I am trying to find arctanhx series. Below is the code

ID: 673433 • Letter: W

Question

What's wrong with this? I am trying to find arctanhx series. Below is the code

# include <stdio.h>
# include <conio.h>
# include <math.h>
void main()
{
int i, n ;
float x, val, sum = 1, t = 1 ;
printf("Enter the value for x : ") ;
scanf("%f", &x) ;
printf(" Enter the value for n : ") ;
scanf("%d", &n) ;
val = x ;
x = x * 3.14159 / 180 ;
for(i = 1 ; i < n + 1 ; i++)
{
t = (double)(1 / (2 * i - 1) * pow(i, 2 * i + 1);

sum = sum + t ;
}
printf(" arctanh value of %f is : %8.4f", val, sum) ;
getch() ;
}

Explanation / Answer

Just remove the '(' before the 1 in the loop step t = (double)(1 / (2 * i - 1) * pow(i, 2 * i + 1); and write it as:

t = (double)1 / (2 * i - 1) * pow(i, 2 * i + 1);

Other than that, everything works good.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote