05 Successive

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 2

NAME: Mayur Khare

CLASS: T.E. [Mech]


ROLL NO.: BM 2018
PROGRAM NAME: Successive For Approximation Method(Based on acc
criteria)

#include<stdio.h>
#include<conio.h>
#include<math.h>
float g(float x)
{
return((x*x+6)/8);
}
float dg(float x)
{
return(x/4);
}
void main()
{
float x1,x2,a,aacc;
clrscr();
printf("\n Enter value of initial guess x1 : ");
scanf("%f",&x1);
printf("\n Enter value for accuracy : ");
scanf("%f",&aacc);
a=dg(x1);
while(fabs(a)>1)
{
printf("\n Enter the value of x1 again : ");
scanf("%f",&x1);
a=dg(x1);
}
x2=g(x1);
while(fabs(x1-x2)>aacc)
{
x1=x2;
x2=g(x1);
}
printf("\n The Root =%f",x2);
getch();

OUTPUT

Enter value of initial guess x1 : 0


Enter value for accuracy : 1
The Root =0.750000
}

You might also like