// // Lab 3 Prelab Program 1 // // A simple program to integrate a function // #include #include // define the function double function(double x); double function(double x) { double foo; foo = (5 * x) + ((sin((9 * x) - 5)) / x); return foo; } int main(void) { double x; double steps; double start; double end; double delta; // Set the time length and step size printf("How many iterations? "); scanf("%lf", &steps); printf("Enter starting point "); scanf("%lf", &start); printf("Enter end point "); scanf("%lf", &end); delta = (end - start) / steps; // // Loop for rectangular integration // total = 0; // set the initial sum to zero for(i = 0; i =< steps; i++) { x = start + i * delta; total = total + function(x); } total = total * delta; printf("Rectangular integration value %f\n", total); return 0; }