Skip to main content

C Program for Euler Method

C Program for Euler Method
#include <stdio.h>
#include <conio.h>
float f(float x,float y)
{return x*y;}
void main()
{
  float x0,y0,xn,yn,h;
  printf("Enter x0, y0 and h: ");
  scanf("%f%f%f",&x0,&y0,&h);
  printf("Enter xn: ");
  scanf("%f",&xn);
  do
  {
    yn=y0+h*f(x0,y0);
    x0=x0+h;
    y0=yn;
  }while(x0<xn);
  printf("y(%0.2f) = %0.4f Ans",xn,yn);
  getch();
}

Comments

Post a Comment

Popular posts from this blog