Sie sind auf Seite 1von 1

#include<stdio.

h>
#include<conio.h>
#include<math.h>
#define f(x,y) x*(1+pow(x,3)*y)
int main()
{
int i,n;
float x0,y0,y1,xn,h;
printf("\nEnter the no. of steps:");
scanf("%d",&n);
printf("\nEnter the initial value of x:");
scanf("%f",&x0);
printf("\nEnter the final value of x:");
scanf("%f",&xn);
printf("\nEnter the initial value of y at x=x0:");
scanf("%f",&y0);
h=(xn-x0)/n;

for(i=0;i<=n;i++)
{
y1=y0+h*f((x0+h/2),y0+(h*f(x0,y0)/2));
printf("\nThe value of y at x=%f= %f .",x0,y0);
x0=x0+h;
y0=y1;
}}
getch();

Das könnte Ihnen auch gefallen