Alex
2012-03-29 09:15:24 UTC
Can anyone see where I'm going wrong and correct it for me??? Thanks
#include
#include
main()
{
float x1,x2,x,series;
double d;
printf("enter x1(pos)\n");
scanf("%f\n",&x1);
printf("enter x2(pos)\n");
scanf("%f",&x2);
x=0;
d=1;
while(d>0.0001)
{
x=(x1+x2)/2;
series=exp(x)-exp(2*x)+exp(-x)-pow(sin(x),4);
d=fabs(series);
if(x*x1 < 0)
x2=x;
else
x1=x;
}
printf("ans=%f",x);
return 0;
}