Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Numerical MethodsRSS Feeds

Program of BIRGT-VIETA METHOD

Posted By: Abel Fischer     Category: C Programming     Views: 4295

Write a program of BIRGT-VIETA METHOD.

Code for Program of BIRGT-VIETA METHOD in C Programming


#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
  float x[10],y[10],z[10],a[10],sum,p,p1,temp;
  int i,n,j,flag=0;
  float fact(int);
  clrscr();
  printf("\nEnter the highest exponent: ");
  scanf("%d",&n);
  for(i=0; i<=n; i++)
  {
   printf("\n\nenter the co-ficent of x^%d: ",i);
   scanf("%f",&x[i]);
  }
  printf("\n\nenter the value of p: ");
   scanf("%f",&p);
  do
  {
    for(i=n;i>=0;i--)
     {
       sum=0,temp=0;
       if(i==n)
    {
      sum=p*x[i];
      z[i]=sum+x[i-1];
      temp=p*x[i];
      a[i]=temp+z[i];
    }
       else
    {
      sum=z[i+1]*p;
      z[i]=sum+x[i-1];
      temp=p*a[i+1];
      a[i]=temp+z[i];
    }
     }
     p1 = p - (z[1]/a[2]);
     printf("\n\n p= %f  ",p1);
     if(fabs(p1-p)<0.0001)
       flag=1;
     else
       p=p1;
  }while(flag  != 1);
printf("\n\nREAL ROOT = %.3f",p1);
getch();
}

/*
______________________________________

OUT PUT
______________________________________


Enter the highest exponent: 5


enter the co-ficent of x^0: 1


enter the co-ficent of x^1: -1


enter the co-ficent of x^2: 0


enter the co-ficent of x^3: 0


enter the co-ficent of x^4: 0


enter the co-ficent of x^5: 1


enter the value of p: -1.5


p= -1.290488

p= -1.190343

p= -1.168275

p= -1.167306

p= -1.167304

REAL ROOT = -1.167

*/
  
Share: 


Didn't find what you were looking for? Find more on Program of BIRGT-VIETA METHOD Or get search suggestion and latest updates.

Abel Fischer
Abel Fischer author of Program of BIRGT-VIETA METHOD is from Frankfurt, Germany.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!