Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<conio.h>
- #include<math.h>
- float function(float);
- int main(){
- float a, A,b, B, c, C, tc, m;
- printf("Enter the two intial range:\n");
- scanf("%f%f",&a,&b);
- A=function(a);
- B=function(b);
- if((A*B)>0){
- printf("\n\nPlease enter valid range.");
- main();
- }
- tc=a;
- do{
- c=(a+b)/2;
- C=function(c);
- if((function(a)*function(c))<0){
- b=c;}
- else{
- a=c;}
- m=tc-c;
- tc=c;
- }while(fabs(m)>0.0009);
- printf("\n\nThe root is: %.4f",c);
- getch();
- }
- float function(float x){
- return((x*x)-(4*x)-10);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement