Where is my mistake? Why is s equal to minus infinity at some loop iterations?

Joined
Oct 9, 2022
Messages
1
Reaction score
0
#include<stdio.h>
#include<math.h>

int main()
{
int a, b, c, i;
double x=-0.8, s, si, eps, y;
printf("Enter eps:");
scanf("%lf", &eps);
for (x=-0.8;x<1;x+=0.2)
{
si=1.0; s=1.0; a=2; b=3; c=4; i=1;
while (fabs(si)<eps)
{
si=(1.0/6)*a*b*c*pow(x,i);
s+=si;
a+=1;
b+=1;
c+=1;
i+=1;
}
y=pow(1-x,-4);
printf("x=%lf\t y=%lf\t s=%lf",x,y,s);
printf("\n\n");

}
return 0;
}
Знімок екрана 2022-10-09 о 18.14.59.png
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,979
Messages
2,570,185
Members
46,723
Latest member
TwilaTarde

Latest Threads

Top