# can someone help

This is a discussion on can someone help within the C Programming forums, part of the General Programming Boards category; Code: no matter what input i give the program it will output area equal to zero, I think my calculation ...

1. ## can someone help

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;
}
```

2. > pow(x,2 );
Where does this result go?

> return 0;
Where does this answer go?
Does it look suspiciously like a zero to you?

Perhaps say
return pow(x,2 );

Popular pages Recent additions