// // Chris Hough // // Final Program 1 - Write a C program to integrate the area beneath the function below: // f(t) = 5t+(sin(9t-5))/t // September 16, 2003 #include #include double step, t_start, t_end, t_delta, t = 0, total_area = 0, i = 0, function; double main(void) { printf("Please enter the starting point of the function: "); fflush(stdin); scanf("%lf", &t_start); printf("Please enter the ending value of the function: "); fflush(stdin); scanf("%lf", &t_end); printf("Please enter the number of steps: "); fflush(stdin); scanf("%lf", &step); t_delta = (t_end - t_start) / step; for(i = 0; i < step; i++) { t = t_start + i * t_delta; function = (5 * t) + ((sin (9 * t - 5)) / t); if (i == 0) total_area = total_area + function; if (i == step) total_area = total_area + function; else total_area = total_area + 2 * function; } total_area = total_area * t_delta / 2; printf("The total area under the curve is: %lf", total_area); return total_area; }