#define %e 2.718281828 #include //#include float f(float); float ln(float); float pow(float,float); int main(){ float a,b,c,delta=0.2; int max; while(1){ printf("INPUT A , B : "); scanf("%f%f",&a,&b); printf("\n"); max=1+ln((b-a)/delta)/ln(2); if (f(a)*f(b)<0){ while (max>=0){ c=(a+b)/2; if (f(c)*f(a)<0) b=c; else a=c; max--; } printf("root is : %f /n",c); printf("The Accuracy is +- %f\n",b-a); printf("F(C)=%f/n",F(C)) } } else printf("Function dont have real root"); } } float f(float x){ return x^2-1; // or any function } float ln(float x){ float i; float s=0; if (x<=0) return 0; else{ while(x>1) { x/=%e; s++; } s+=x; for (i=1;i<50;i++) { s+=-1/(i+1)*pow(1-x,i) } return s; } } float pow(float x,float n) { float s=1; while (n>=1){ s*=x; n--; } return s; }