Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<conio.h>
- #include<math.h>
- float f(float);
- float f1(float);
- int main(){
- float x, x1,x2,y,t,m;
- printf("Enter the intial value:\n");
- scanf("%f",&x);
- x1=f(x);
- x2=f1(x);
- if(x2==0){
- printf("\nError!");
- main();
- }
- do{
- t=x;
- y=x-(f(x)/f1(x));
- m=t-y;
- x=y;
- }while(fabs(m)>0.0009);
- printf("\n\nThe root is: %.4f",y);
- getch();
- }
- float f(float x){
- return((x*x)-(4*x)-10);
- }
- float f1(float x){
- return((2*x)-4);
- }
Add Comment
Please, Sign In to add comment