euler
DESCRIPTION
eulers programTRANSCRIPT
/*Eulers Method*/
#include<stdio.h>#include<conio.h>#include<math.h>#define f(x0,y0) ((2*y0/x0)+(x0*x0*x0))main(){
int i=1,n;float x0,y0,h=0.2;printf("enter x0,y0, no. of iterations\n");scanf("%f %f %d",&x0,&y0,&n);for(i=1;i<n+1;i++){
printf(" the values at %d iteration is ",i);y0=y0+(h*f(x0,y0));x0=x0+h;printf("y=%f,x=%f \n",y0,x0);
}}
Output:
enter x0,y0, no. of iterations10.52 the values at 1 iteration is y=0.900000,x=1.200000 the values at 2 iteration is y=1.545600,x=1.400000