-->

Facebook

Jasper Roberts - Blog

Monday, March 2, 2015

A C Program to represent Secant Method.

#include<stdio.h>
#include<conio.h>
double f(double x)
{
return (2*x*x*x-3*x*x+5*x-6);
};
void main()
{
int iter,ctr=1;
double x0,x1,r;
clrscr();
printf("\nEnter the first approximate value : ");
scanf("%lf",&x0);
printf("\nEnter the second approximate value : ");
scanf("%lf",&x1);
printf("\nEnter the number of itteration : ");
scanf("%d",&iter);
while(ctr<=iter)
{
r=((x0*f(x1))-(x1*f(x0)))/(f(x1)-f(x0));
printf("\nAfter %d itteration root is = %lf",ctr,r);
x0=x1;
x1=r;
ctr++;
};
printf("\n\nThe approximate root is = %lf",r);
getch();
}


RELATED TOPICS
A C Program to represent N-R Method.
A C Program to represent the Bisection Method.

No comments:

Post a Comment