#include<stdio.h>
# include<math.h>
main()
{
float i,a,b,c,t=0;
for(i=0;;i++)
{
if(f(i)>0&&f(i+1)<0)
{
a=i;b=i+1;break;}
if((f(i)<0)&&(f(i+1)>0))
{
a=i+1;b=i;break;}
}
for(i=0;;i++)
{
c=(a+b)/2;
if(f(c)>0)
a=c;
else
b=c;
if(fabs(c-t)<=.00005)
break;
}
printf("\nthe root is %f",c);
}
very good program, no function,reselt for any function.
ReplyDeletewhat does this mean"reselt for any function."
Deleteabe result for any function
Delete