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

input data:- 56200.28 12300.36 67800.98 68700.68 59300.43 65778.29 67900.94 2340

ID: 3827360 • Letter: I

Question

input data:-

56200.28    12300.36    67800.98    68700.68    59300.43    65778.29
67900.94    23400.67    89000.52    87900.90    34500.88    36549.45
45600.89    54300.12    56700.45    45800.39    66700.88    76543.24
35600.12    86400.97    67300.51    85900.71    12300.69    26574.27
45678.13    65437.78    76312.14    38765.87    34598.53    65487.89

--------

This is what i have done so far, and it gives me errors:-

-----------------------------------------------------------------------------------------------

#include <stdio.h>

const int ARSIZE = 5;
const int CSIZE = 6;

FILE *inptr, *outptr;

void fninput(float [ ][CSIZE]);
void fncompute(float [ ][CSIZE], float [ ][CSIZE]);
void fnrowcolumnsums(float [ ][CSIZE], float [ ], float [ ]);
void fnoutput(float [ ][CSIZE]);

int main( )
{
  
   float depth[RSIZE][CSIZE], avdepthrsum[RSIZE], avsepthcsum[CSIZE];
   float pressure[RSiZE][CSIZE];

   inptr = fopen("proj7in.dat", "r");
   outptr = fopen("proj7out.dat", "w");


   fninput(depth);
   fncompute(depth, pressure);
   fprintf(outptr,"                               DEPTH ARRAY ");
   fprintf(outptr,"                               ============ ");
   fnoutput(depth);
   fprintf(outptr,"                           PRESSURE ARRAY ");
   fprintf(outptr,"                               ============= ");
   fnrowcolumnsums[pressure,
   fnoutput(pressure, avpressuresum, avpressurecsum);

    return 0;
  
}

/**********************************************************/
/*                                                        */
/*                ARRAY DEPTH INPUT FUNCTION              */
/*                                                        */
/**********************************************************/


void fninput(float d[ ][CSIZE])
{
     int i, j;
   
     for(i = 0; i < RSIZE; i++)
     {
         for(j = 0; j < CSIZE; j++)
         {
             fscanf(inptr, "%f   ", &d[i][j]);
           
         }
     }
}


void fnoutput(float d[ ][CSIZE], float p[ ][CSIZE]);
{
     void fninput(float d[ ][CSIZE])
{
     int i, j;
   
     for(i = 0; i < RSIZE; i++)
     {
         for(j = 0; j < CSIZE; j++)
         {
             p[i][j] = 0.4333 * d[i][j];
                

/**********************************************************/
/*                                                        */
/*                COMPUTE THE PRESSURE ARRAY              */
/*                                                        */
/**********************************************************/

void fmcompute(float d[ ][CSIZE], float p[ ][CSIZE]
{
     int i, j;
   
     for(i = 0; i < RSIZE; i++)
     {
         for(j = 0; j < CSIZE; j++)

------------------------
void fnrowcolmsums(float x[ ][CSIZE], float xrsum[RSIZE], float xcsum[CSIZE])
{
     int i, j;
   
     for(i= 0; i < RSIZE; i++)
     {
            for(j = 0; j < CSIZE; j++)
            {
                  *(xrsum + i) = *(xrsum + i) + *(*x + i)+ j));
            }
          
            *(xrsum + i) = *(xrsum + i) / CSIZE;
          
     }
   
     for(j = 0; j < CSIZE; j++)
     {
           *(xrsum + i) = 0.0;
         
           for
         
          

           
           
           
           
           

/**********************************************************/
/*                                                        */
/*                ARRAY DEPTH OUTPUT FUNCTION             */
/*                                                        */
/**********************************************************/

void fnoutput(float x[ ][CSIZE], float avxsum[RSIZE], float avxcsum[CSIZE])

{
     int i, j
   
     for(i = 0; i < RSIZE; i++)
     {
           for(j = 0; j < CSIZE; j++)
         {
                 fprintf(outptr, "%10.2f   ", x[i][j]);
                 }
                 fprintf(outptr, "%12.2f   ", avxrsum[i]);
         }
       
         for( j = 0; j < CSIZE; j++)
         {
              fprintf(outptr, "%12.2f   ", avxcsum[j]);
            
         }
}

Objectives: Learn the following concepts Definition of two-dimensional arrays Input and output of two-dimensional arrays Manipulation of two-dimensional arrays using array index Processing two-dimensional arrays using functions rite a main program and the following functions to manipulate two-dimensional arrays Create a header file to include the system header files, defined constants, and the function prototypes. Use the header file you created. l. Write a function to input the given of depth measurements in a two-dimensional array, and return the array to the main program by invoking the input function in the main program. 2. Write a function to compute the pressure using the given formula and return the value of pressure to the main program through the return statement and store the values of pressure in a two dimensional array 3. Write a function to compute the average depth of each row and an average depth of each column and store the average depths of each row and each column in separate one-dimensional arrays 4. Write a function to compute the average pressure of each row and an average pressure of each column and store the average pressures of each row and each column in separate one-dimensional arrays 5. Write a function to output the depth array, average depth of each row and average depth of each column and output the pressure array, average pressure of each row and average pressure of column

Explanation / Answer

#include <stdio.h>
const int RSIZE = 5;
const int CSIZE = 6;
const float constant_p = .4333;
FILE *inptr, *outptr;
void fninput(float[][CSIZE]);
void fncompute(float[][CSIZE], float[][CSIZE]);
void fnrowcolumnsums(float[][CSIZE], float[], float[]);
void fnoutput(float[][CSIZE], float[], float[]);
int main()
{

   float depth[RSIZE][CSIZE], avdepthrsum[RSIZE], avsepthcsum[CSIZE];
   float pressure[RSIZE][CSIZE];
   float avgpressure_rsum[RSIZE], avgpressure_csum[CSIZE];

   fopen_s(&inptr,"proj7in.txt","r");
   fopen_s(&outptr,"proj7out.txt", "w");


   fninput(depth);
   fncompute(depth, pressure);
   fnrowcolumnsums(depth, avdepthrsum, avsepthcsum);
   fnrowcolumnsums(pressure, avgpressure_rsum, avgpressure_csum);

   fprintf(outptr, " DEPTH ARRAY ");
   fprintf(outptr, " ============ ");
   fnoutput(depth, avdepthrsum, avsepthcsum);


   fprintf(outptr, " PRESSURE ARRAY ");
   fprintf(outptr, " ============= ");
   fnoutput(pressure, avgpressure_rsum, avgpressure_csum);
  

   return 0;

}
/**********************************************************/
/* */
/* ARRAY DEPTH INPUT FUNCTION */
/* */
/**********************************************************/

void fninput(float d[][CSIZE])
{
   int i, j;

   for (i = 0; i < RSIZE; i++)
   {
       for (j = 0; j < CSIZE; j++)
       {
           fscanf_s(inptr, "%f ", &d[i][j]);

       }
   }
}
/**********************************************************/
/* */
/* COMPUTE THE PRESSURE ARRAY */
/* */
/**********************************************************/
void fncompute(float d[][CSIZE], float p[][CSIZE])
{
   int i, j;
   for (i = 0; i < RSIZE; i++)
   {
       for (j = 0; j < CSIZE; j++)
       {
           p[i][j] = constant_p*d[i][j];
       }
   }
}
/**********************************************************/
/* */
/* COMPUTE THE PRESSURE/DEPTH row/col average ARRAY */
/* */
/**********************************************************/
void fnrowcolumnsums(float d[][CSIZE], float row[], float col[])
{
   float col_avg = 0, row_avg = 0;
   int i, j;
   //for calculating row average
   for (i = 0; i < RSIZE; i++)
   {
       row_avg = 0;
       for (j = 0; j < CSIZE; j++)
       {
           row_avg = row_avg + d[i][j];
       }
       row[i] = row_avg;
   }
   //for calculating column average
   for (i = 0; i < CSIZE; i++)
   {
       col_avg = 0;
       for (j = 0; j < RSIZE; j++)
       {
           col_avg = col_avg + d[j][i];
       }
       col[i] = col_avg;
   }

}
/**********************************************************/
/* */
/* ARRAY OUTPUT FUNCTION */
/* */
/**********************************************************/

void fnoutput(float x[][CSIZE], float avxrsum[RSIZE], float avxcsum[CSIZE])
{
   int i, j;
   for (i = 0; i < RSIZE; i++)
   {
       for (j = 0; j < CSIZE; j++)
       {
           fprintf(outptr, "%10.2f ", x[i][j]);
       }
           fprintf(outptr, " ");
   }

   fprintf(outptr, " Row Averages: ");
   for (j = 0; j < RSIZE; j++)
       fprintf(outptr, "%12.2f ", avxrsum[j]);

   fprintf(outptr, " Column Averages: ");
   for (j = 0; j < CSIZE; j++)
       fprintf(outptr, "%12.2f ", avxcsum[j]);
}