Euler Method
#include<stdio.h>
#include<conio.h>
#include<math.h>
float
f(float x,float y)
{
return
(x-(y*y));
}
void main()
{
float
x0,y0,xg,yg,h;
int 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 step size h= ”);
scanf(“%f”,&h);
n=(xg-x0)/h;
for(i=1;i<=n;i++)
{
yg=y0+h*f(x0,y0);
x0=x0+h;
y0+yg;
}
printf(“The
final value of yg=%f”,y0);
getch();
}
Output
Euler’s Method