#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
float
x1,y1,x2,y2,xf,h,s,s1,s2,s3,s4;
//clrscr();
printf("enter the
initial points :\n");
scanf("%f%f",&x1,&y1);
printf("enter the
final points :\n");
scanf("%f",&xf);
printf("enter the
step size :\n");
scanf("%f",&h);
//printline();
printf("X\t\tY\n");
//printline();
printf("%.2f\t\t%.2f\n",x1,y1);
while(x1<=xf)
{
s1=1-(x1*x1*x1);
x2=x1+(h/2);
y2=y1+(s1*(h/2));
s2=1-(x1*x1*x1);
y2=y1+(s2*(h/2));
s3=1-(x1*x1*x1);
x2=x1+h;
y2=y1+(s3*h);
s4=1-(x1*x1*x1);
s=(s1+2*s2+2*s3+s4)/6;
y2=y1+h*s;
x1=x2;
y1=y2;
printf("%.2f\t\t%.2f\n",x1,y1);
}
getch();}
No comments:
Write comments