Modify Program
#include<stdio.h>
#include<conio.h>
#include<math.h>
float
f(float x,float y)
{
return(sqrt(x+y));
}
void main()
{
float
x0,y0,xg,acc,h,y1,y11,i,n;
clrscr();
printf("enter
the initial value of x0=");
scanf("%f",&x0);
printf("enter
the value of y0=");
scanf("%f",&y0);
printf("enter
the value of xg=");
scanf("%f",&xg);
printf("enter
the value of desired accuracy=");
scanf("%f",&acc);
n=2;
h=(xg-x0)/n;
for(i=1;i<=n;i++)
{
y1=y0+h*f(x0,y0);
y11=y0+(h/2)*(f(x0,y0)+f((x0+h),y1));
while(fabs(y11-y1)>acc)
{
y1=y11;
y11=y0+(h/2)*(f(x0,y0)+f((x0+h),y1));
}
x0=x0+h;
y0=y11;
}
printf("the
final value of yg=%f",y11);
getch();
}
Output
Modify