Euler’s Method

Euler’s Method

#include<stdio.h>
#include<conio.h>
#define F(x) 3*x*x+1
int main (void)
{
   float a,c,b,h,x,f,i,y2;
   clrscr();
   printf("Enter the value of a & c as y(a)=c: ");
   scanf("%f %f",&a,&c);
   printf("Enter the value of b as y(b)=?");
   scanf("%f",&b);
   printf("Enter the value of h: ");
   scanf("%f",&h); 
   x=a;
   for(i=a;i<b;i=i+h)
   {
      f= F(x);
   	y2=c+ h*f;
      c=y2;
      x=x+h;
   }
   printf("\nRequired ans: %f",y2);
   getch();
   return 0;
}

Related posts:

Leave a Reply

Your email address will not be published. Required fields are marked *