C Program to solve using Euler Rule
/*
Euler Rule
Compute:: f(0.1)=?
When f(x,y)=1+xy, y(0)=2,h=0.01
*/
#include<conio.h>
#include<stdio.h>
void main()
{
float x0,y0,h,xf,fx,x;
float f(float,float);
printf("\nEnter x0 & y0");
scanf("%f%f",&x0,&y0);
printf("\nEnter x & h");
scanf("%f%f",&x,&h);
xf=x0;fx=y0;
while(xf<=x)
{
fx=fx+h*f(xf,fx);
xf=xf+h;
}
printf("\nResult %f",fx);
getch();
}
float f(float x,float y)
{
return 1+x*y;
}
Comments
Post a Comment