Program Does Numerical Integration For Data Sets Located in an Input File. The Code has to be All C language no C++

Paste Bin Link to The Full Code
http://pastebin.com/NRVDqxdj

Could Someone Help Me With This:

Calculate the total area under the curve for this data set, starting with an h value of 0.1 and then continuing with h = 0.01, 0.001, etc. [b]until the latest two calculations are within 0.0005 of each other, or h becomes 0.00001.[/b] For each of these calculations report the h value, the value of N and the area calculated.

The Section in Bold is The Bit Where im Confused on How to Do It

Another Problem Im Having is Creating My Own Functions:
These Calculations I Want in Functions But Can't Figure It Out

for ( Height = 0.1; Height >= 0.00001; Height = Height * 0.1 ){

    N = (X_Final - X_Initial) / ( Height ) + ( 0.5 );                                       

    X_a = X_Initial;                    

    Area_Total = 0;                                                 

    for ( int i = 0 ; i < N ; i++){

        X_b = X_a + Height;                                             

        Area_i = Height * (abs(X_a*X_a + B*X_a + C + D/X_a) + abs(X_b*X_b + B*X_b + C + D/X_b)) * 0.5;  

        Area_Total = Area_i + Area_Total;                                           

        X_a = X_b;

}

Also if You See anything Else That Needs Fixing Can You Please Post it
- Such as The Formatting

Thanks In Advance

Format for creating user defined function is

 return_type function_name ( arguments )
 {
    //function body

 }

Also in the code posted, one ' } ' is missing.

You are calculating the area under curve. Do the calculations inside a functionand return the answer.

For example :

double CalcArea( X_final, X_Initial, // other arguments )
{
     double Area_Total = 0 ;

     // calculate the area here and store it in a variable say Area_Total  

     return Area_Total ;
}

Edited 4 Years Ago by np complete

Sorry But i Don't Understand =( and where abouts is the "}" missing

Edited 4 Years Ago by Soup12

Also Need Help On

Calculate the total area under the curve for this data set, starting with an h value of 0.1 and then continuing with h = 0.01, 0.001, etc. until the latest two calculations are within 0.0005 of each other, or h becomes 0.00001. For each of these calculations report the h value, the value of N and the area calculated

How Would I Achieve This?

would have to be like

Area_Total_Check = Area_Total (Previous Example) - Area_Total (Newest Value);
    if ( Area_Total_Check = 0.0005 || h = 0.00001 ){
        input_status = fscanf(inp, "%d %d %d %lf %lf", &B, &C, &D, &X_Initial, &X_Final);   
        }
        else
        {
            /* Continue to Calculate till it does that */
This article has been dead for over six months. Start a new discussion instead.