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

Programming in C, 1-7 Chapter 3 section 3.7, and Chapter 5 section 5.8 of Delore

ID: 3940190 • Letter: P

Question

Programming in C, 1-7

Chapter 3 section 3.7, and Chapter 5 section 5.8 of Delores Etter’s Engineering Problem Solving with C. Answer the questions below in a typed document, numbered appropriately. Thank you!

1) Write a declaration statement for a 1-D array called timedata with a length of n, where n is a pre-declared integer variable. (In other words, n has already been declared in advance.) (Remember, you cannot initialize variable-length arrays in a declaration statement) 2) Write a declaration statement for a 2-D array called wavedata with a width of 2 and a length of 10 3) Write the same declaration, but for a 2-D array with a width of 2 and a length of rn Write the declaration statement for a file pointer to represent wave data, and then write a file assignment statement for that pointer that opens a file, defined as a symbolic constant FILENAME, as a read file. 4)

Explanation / Answer

[1]
int timedata[n];

[2]
int wavedata[2][10];

[3]
int wavedata[2][n];

[4]
FILE *ptr = wavedata;
ptr = fopen("FILENAME.txt", "r");

[6]

FOR(j=0;j<2;j++)
{
  
FOR(i=0;i<n;i++)
{
SUM_COL=SUM_COL + wavedata [j][i];
}
AVG_COL=SUM_COL / n;
printf("Average of column %d is %d",i,AVG_COL);

SUM_COL = 0;
AVG_COL = 0;
}


[7]

Percent Difference = abs(((A-B) / ((A+B)/2))*100);