You are on page 1of 2

Er.

Puneet kumar tyagi

AIM :- Write a program for EULERS METHOD

#include<stdio.h>
#include<conio.h>
#include<math.h>
float f(float x,float y)
{
return(x-(y*y));
}
void main()
{
float x0,xg,y0,yg,h;
int i,n;
clrscr();
printf("\n enter the initial value of x0");
scanf("%f", &x0);
printf("\n enter the initial value of y0");
scanf("%f", &y0);
printf("\n enter the given value of xg");
scanf("%f", &xg);
printf("\n enter the given value of step size h-");
scanf("%f", &h);
n=xg-x0/h;
for(i=0;i<=n;i++)
{
yg=y0+h*f(x0,y0);
x0=x0+h;
y0=yg;
}
printf("\n the final value of yg=%f",y0);
getch();
}
Er.Puneet kumar tyagi

OUTPUT

Enter the initial value of x0-0


Enter the initial value of y0-1
Enter the given value of xg-4
Enter the given value of step size h-1
The final value of yg=4.000000

You might also like