diff --git a/computer_oriented_statistical_methods/simpson's 1-3rd rule.c b/computer_oriented_statistical_methods/simpson's 1-3rd rule.c index 7c04b89c..fe083b89 100644 --- a/computer_oriented_statistical_methods/simpson's 1-3rd rule.c +++ b/computer_oriented_statistical_methods/simpson's 1-3rd rule.c @@ -1,34 +1,41 @@ -#include #include #include -float f(float x) + +float f(float x) { - return 1.0+x*x*x; + return 1.0+x*x*x; //This is the expresion of the function to integrate? } + void main() { int i,n; float a,b,h,x,s2,s3,sum,integral; - printf("enter the lower limit of the integration"); - sacnf("%f",&a); - printf("enter the upper limit of the integration"); - sacnf("%f",&b); - printf("enter the number of intervals"); - sacnf("%d",&n); + + printf("enter the lower limit of the integration:"); + scanf("%f",&a); + printf("enter the upper limit of the integration:"); + scanf("%f",&b); + printf("enter the number of intervals:"); + scanf("%d",&n); + h=(b-a)/n; sum=f(a)+f(b); s2=s3=0.0; - for(i=1;i