Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<conio.h>
- #include<stdlib.h>
- #include<math.h>
- float function(float);
- int main() {
- float a, A, b, B, c, C, tc, m;
- printf("Enter values of x1 and x2:\n");
- scanf("%f%f",&a,&b);
- A=function(a);
- B=function(b);
- if(A==B){
- printf("Error, Enter valid values.");
- exit(1);
- }
- tc=b;
- do {
- A=function(a);
- B=function(b);
- c=(((a*B)-(b*A))/(B-A));
- a=b;
- b=c;
- m=tc-c;
- tc=b;
- }while(fabs(m)>0.0009);
- printf("\n\nThe root is: %.4f",c);
- getch();
- }
- float function (float x) {
- return ((x*x)-(8*x)-14);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement