Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need a C program that can do the below, very important is that it should be wr

ID: 3624869 • Letter: I

Question

I need a C program that can do the below, very important is that it should be written in C++ dev HOWEVER it has to be a .c program so you can only use commands that are valid for .c and not C++ commands.

I have a little outline but I cant seem to get the code to work. the question is:

Write a C program that reads in the Y values of a function provided in data.txt. The Y values correspond to an X domain ranging from -3 to 6 with a step size of 0.01. The program must use a function that performs the numerical differentiation method described below to calculate the derivative of the input data and write the resulting X and Y values to a CSV file. Corresponding X and Y values must be separated by a comma and subsequent data points must be separated by new lines.

In our case the size of h is our step size and if we perform this calculation between each data point we will get the derivative of the function.

That is a part of the code I cant get to work, in short I have to make a graft that takes Y values from a data.txt and plots a graft then does the derivtive.

The Data.txt has the below values in

Explanation / Answer

const double h = .01; const double low = -3; const double high = 6; double f(double y1, double y2); int main() { FILE *fp, *out; fp = fopen("data.txt", "r"); if (fp==NULL) { printf("That file did not work out..."); } out = fopen("output.csv", "w"); if(out == NULL) { printf("Output not working..."); } double d1, d2; int x = low; fscanf("%f", &d2) while(fp->open) { x+=h; fscanf("%f", &d1); fprintf(out,"%f,%f ", x, f(d1,d2)); } fclose(fp); fclose(out); } double f(double y1, double y2) { return (d1-d2)/h; }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote