1. EULER’S METHOD IN C
Date:-
Write a C program to solve the differential equation
for x=0(0.05)0.4By Euler method correct up to 5 decimal places,given that y=0 for
x=0
Program code:-
#include<stdio.h>
#include<math.h>
float f(float x,float y);
int main()
{
float x0,xn,y0,h;
x0=0;
xn=0.4;
y0=0;
h=0.05;
printf("t xtt yn n");
while(x0<xn)
{
y0=y0+h*f(x0,y0);
x0=x0+h;
printf("%12.5f t %12.5fn",x0,y0);
}
}
float f(float x,float y)
{
float z;
z=(1.+x*y)/(1.+10.*pow(y,2.));
return(z);
}