Code:
no matter what input i give the program it will output area equal to zero, I think my calculation are correct but I think it's not going through the loop or the communitcaion with my function is non-existence.
Code:
#include <stdio.h>
#include <math.h>
double f(int x){
pow(x,2 );
return 0;
}
int main(void)
{
int a, b, N, width, i, sum,value, area;
printf (" Enter the interval a an b");
scanf ("%d\n%d", &a, &b);
printf (" Enter the number of trapezoids you would like to use");
scanf ("%d", &N);
width = (b-a)/N;
sum=(f(a) + f(b))/2;
for (value = a + width; value < b; value += width)
sum += f(value);
area = sum * width;
printf (" The area under the curv is %d\n", area);
return 0;
}