Friday, April 10, 2015

Differential Equation by Euler's Method

#include<stdio.h>
#include<conio.h>
#define f(x,y) (3+x*x+1)
 void main()
{
int i,n;
float x0,y0,h,x,y[10];
clrscr();
printf("\ enter the initial value of x & Y:");
scanf("%f %f"&x0,&y0);
printf("Enter the value of x where we have to find y(x):");
scanf("%f",&x);
n=(x-x0)/h;
printf("\n No. of calculation =%d,n);
for(i=1;i<=n;i++)
{
y[i]=y0+f(x0,y0)*h;
x0 =x0+h;
y0=y[i];
}
printf("\n y(x) at x is =%f",y0);
getch();
}

No comments:

Post a Comment