[ New messages · Members · Forum rules · Search · RSS ]
  • Page 1 of 1
  • 1
Forum » Codeing » C ++ Examples of maths » Euler's Method (Euler's Method tested)
Euler's Method
pradeepDate: Wednesday, 02 November 11, 6:49 PM | Message # 1
pk
Group: Administrators
Messages: 82
Status: Offline
Quote
/* Euler's Method */
#include
#include
#include
#define f(x,y) (y-x)/(y+x)/* R.H.S of the equation */
void main()
{
float x, y, h, xn;
int i = 0, n;
clrscr();
printf(" Enter the initial values of x and y : ");
scanf("%f%f", &x, &y );
printf("\n Enter x at which y is required :");
scanf("%f",&xn);
printf("\n Enter step size h : ");
scanf("%f",&h);

n= ((xn-x)/h+0.5);
printf("\n\n step x y\n\n");
while(x { y=y+h*f(x,y);
x=x+h;
i=i+1;
printf("%3d%10.4f%10.4f\n",i,x,y);
}
printf("\n value of y at x = %f is %f\n\n",x,y);
getch();
}

 
Forum » Codeing » C ++ Examples of maths » Euler's Method (Euler's Method tested)
  • Page 1 of 1
  • 1
Search: