pradeep | Date: Wednesday, 02 November 11, 6:46 PM | Message # 1 |
pk
Group: Administrators
Messages: 82
Status: Offline
| #include #include #include #define f(x) x*x+x-2.0*x-5.0 void main() { float x,x0,x1,x2,y0,y1,y2,e; int max,i; clrscr(); printf("Input Two initial Starting Roots\n:"); scanf("%f%f",&x0,&x1); printf("Input the tolerance value\n"); scanf("%f",&e); y0=f(x0); y1=f(x1); if(y0*y1>0.0) { printf("\ Initial roots are unsuitable\n"); } else { while((fabs(x1-x0)/x1) { x2=(x0+x1)/2; y2=f(x2); if(y0*y2>0) x0=x2; else x1=x2; } printf("\solution is converge\n"); printf("\Root of the given equation is =%8.4f\n",x2); } getch(); }
If any error send feed back
|
|
| |