Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Numerical MethodsRSS Feeds

Program of EULER'S METHOD

Posted By: Betty Fischer     Category: C Programming     Views: 31298

Write a program of EULER'S METHOD.

Code for Program of EULER'S METHOD in C Programming

#include<stdio.h>
#include <math.h>
#include<conio.h>
//dy/dx = xy#define F(x,y)  (x)*(y)
void main()
{
  double y1,y2,x1,a,n,h;
  int j;
  clrscr();
  printf("\nEnter the value of range: ");
  scanf("%lf %lf",&a,&n);
  printf("\nEnter the value of y1: ");
  scanf("%lf",&y1);
  printf("\n\nEnter the h: ");
  scanf("%lf",&h);
  printf("\n\n  y1 = %.3lf ",y1);
  for(x1=a,j=2; x1<=n+h; x1=x1+h,j++)
  {
   y2= y1 + h * F(x1,y1);
   printf("\n\n  x = %.3lf => y%d = %.3lf ",x1,j,y2);
   y1=y2;
  }
getch();
}

/*
OUT PUT
---------


Enter the value of range: 1 1.5

Enter the value of y1: 5


Enter the h: 0.1


y1 = 5.000

x = 1.000 => y2 = 5.500

x = 1.100 => y3 = 6.105

x = 1.200 => y4 = 6.838

x = 1.300 => y5 = 7.726

x = 1.400 => y6 = 8.808

x = 1.500 => y7 = 10.129



*/
  
Share: 


Didn't find what you were looking for? Find more on Program of EULER'S METHOD Or get search suggestion and latest updates.

Betty Fischer
Betty Fischer author of Program of EULER'S METHOD is from Frankfurt, Germany.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
Swaroopa Awasthi from India Comment on: Oct 13
correction
 printf("\n\n  x = %.3lf => y%d = %.3lf ",x1,j,y1);[\code]

View All Comments