All Programs are Written and Compiled in Dev C++. So, it may generate some error in case of other compilers and may need some modifications in program. Download Dev C++

Wednesday 22 April 2015

Trapezoidal Rule to find Integration of Diff.-Table

#include<iostream>
using namespace std;
int main()
{
    int i,j,k,n;
    float x[10],y[10],sum,h;
    cout<<"Enter no of Values in table: ";
    cin>>n;
    cout<<"Enter X and corresponding Y\n";
    for(i=0;i<n;i++)

        cin>>x[i]>>y[i];
    h=x[1]-x[0];
    sum=y[0]+y[n-1];
    for(i=1;i<n-1;i++)
        sum+=2*y[i];
    cout<<"Integral value="<<(h/2)*sum;
    return 0;
}

No comments:

Post a Comment