0
Hi everyone! Can you help me solve this problem? The program is in C
#include <stdio.h> #include <math.h> int main() { double n=1.0, m=1.0; printf("Enter eps: "); scanf("%lf", &eps); for ( x = -0.9; x <= 0.9; x+= 0.1){ si = x/2.0, s = 1 + si; while (fabs(si) > eps) { si= si*pow(-1,n)*(pow(x,n)*( (2*n-1) / (2*m+2))); s = s + si; n++; m++; } n=1; m=1; y = sqrt(x+1); printf("|\t%f\t|\t%f\t|\t%f\t\n", x,y,s); s=0; } return 0; } The middle and right column must be the same
4 ответов
+ 1
Julia Sagan In your code there are lots of mistakes some variable are showing undeclared and some are used wrongly somewhere you missed semicolon u have written command instead of semicolon first thing u need to declear these variables
x ,y ,si ,eps ;
Then u need to check you loop its ok but your loop condition is <= so it will execute 1 times then inside loop u have written si=x/2.0 after that u need semicolon u have written comma
Rest of the things seem correct i guess
+ 1
I just started learning C 3 weeks ago. Sherine, thank you so much!
0
Try this one
#include <stdio.h>
#include <math.h>
int main()
{
double n=1.0, m=1.0,eps, y,x,si,s;
printf("Enter eps: ");
scanf("%lf", &eps);
for ( x = -0.0; x <= 0.9; x+= 0.1){
si = x/2.0;
s = 1 + si;
while (fabs(si) > eps)
{
si= si*pow(-1,n)*(pow(x,n)*( (2*n-1) / (2*m+2)));
s = s + si;
n++;
m++;
}
n=1; m=1;
y = sqrt(x+1);
printf("|\t%f\t|\t%f\t|\t%f\t\n", x,y,s);
s=0;
}
return 0;
}
0
Julia Sagan dont worry keep learning you have learnt a lot in 3 weeks and also when u face errors try to read them why compiler showing error then u will be able to solve your error self .