Hello

I was wondering if you could help. I wish to be able to compute pi on C using the composite trapezoidal rule. Basically work out the area of a circle with radius 1, with limits from -1 to 1, by dividing it up into trapeziums and using the equation area = h(1/2f(-1) + f(-0.75) ...+ f(1). The function f being (1-x^2)^0.5. I know this can be done by usinga for loop but I keep on getting stuck on the start on the iteration.

I would be very grateful if you could help me with this.

Thank you very much

Sam

Here is the code so far....its terrible i know

include <stdio.h>

include <math.h>

int square(int a) {

return 0

}

int main (void) {

int a = -1

int b = 1

double h = (double) (b-a) /n

int n = 10

double area = (h/2)* (1-((square)-1))^0.5 + 1-((square)1))^0.5)

I know its something to do with the matsh, ie the ^0.5, but I dont know what it is! Please help!

Thank you

sam