this is my modified code (declared prototypes, tried to fix the factorial equation):

Code:

#include <stdio.h>
#include <math.h>
double Intgr(double m, int n, double A, double a, double b);
double func(double x, double m, int n, double A);
double nfact(int n);
int main()
{
int n;
double m, A, a, b;
printf("\nEnter the exponents (double)m and (int)n in f(x)=A*x^m/n! : ");
scanf("%lf %lf", &m,&n);
printf("\nEnter the coefficient A in f(x)=A*x^m/n! : ");
scanf("%lf",&A);
printf("\nEnter bounds for integration interval, a < b : ");
scanf("%lf %lf", &a,&b);
Intgr(m,n,A,a,b);
}
double Intgr(double m, int n, double A, double a, double b)
{
int n_trap, k;
double del_x, x, f, sum;
printf("\nIntegrate f(x) on [a,b]\n");
printf("Enter the number of trapezoids: ");
scanf("%d", &n_trap);
del_x = (b-a)/(double)n_trap;
x = a;
f = func(x, m, n, A);
sum = - 0.5 * f;
for(k=0; k<=n_trap; k++)
{
x = a + k * del_x;
f = func(x, m, n, A);
sum += f;
}
sum -= 0.5 * f;
sum *= del_x;
printf("\nIntegral=%f\n", sum);
}
double func(double x, double m, int n, double A) {
if (n == 0)
return A * pow(x,m);
else
return (A* pow(x,m)) / nfact(n);
}
double nfact(int n){
int t = 1;
int as;
for (as = 1; as<=n; as++) {
t *=as;
}
return t;
}

It compiles with no warnings but my output seems to stop after I "Enter the number of trapezoids : 1000".

My output:

Code:

Enter the exponents (double)m and (int)n in f(x)=A*x^m/n! : 3.25 5
Enter the coefficient A in f(x)=A*x^m/n! : -1.5
Enter bounds for integration interval, a < b : 1.5 3.75
Integrate f(x) on [a,b]
Enter the number of trapezoids: 1000

And it freezes right there. Why is it not calculating my integral?