C code using Trapezoidal Rule

Problem: Here we have to find integration for the (1/1+x*x)dx with lower limit =0 to upper limit = 6

Algorithm:

Step 1: input a,b,number of interval n

Step 2:h=(b-a)/n

Step 3:sum=f(a)+f(b)

Step 4:If n=1,2,3,……i

Then , sum=sum+2*y(a+i*h)

Step 5:Display output=sum *h/2

 

Code:

Output:

2014-11-27 08_59_58-