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

I am programming a project in c programming language, and I need some help. #inc

ID: 3801596 • Letter: I

Question

I am programming a project in c programming language, and I need some help.

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <math.h>

#include <time.h>

int **allocateMatrix(int, int);

void initMatrix(int **, int, int);

int findRange(int **, int, int);

double findAverage(int **, int, int);

void printCorners(int **, int, int);

int main(int argc, char *argv[]) {

srand(0);

int row = atoi(argv[1]);

int col = atoi(argv[2]);

data = allocateMatrix(row, col),

initMatrix(data, row, col);

printf("Range of values in the array is %d ", findRange(data, row, col) );

printf("Average of all array values i %lf ", findAverage(data, row, col) );

printCorners(data, row, col);

return 0;

}

CS 100 Lab Seven Spring 2017 Create a directory called lab7 on your machine using mkdir lab7 Within this directory, complete the program named lab7.c that is shown below. You need to write the five functions shown in red #include

Explanation / Answer

int **allocateMatrix(int nrows,int ncolumns){
int i;
int **array1 = malloc(nrows * sizeof(int *));
for(i = 0; i < nrows; i++)
array1[i] = malloc(ncolumns * sizeof(int));
return array1;
}

void initMatrix(int **arr,int x,int y){
int **data;
time_t t;
int i,j;
srand((unsigned) time(&t));
for (i = 0; i < x; i++) {
      for (j = 0; j < y; j++) {
          data[i][j] = rand() % 1000;
      }
}
*arr = data;
}
void printCorners(int **arr,int row,int col){
printf ("%d %d %d %d",arr[o][0],arr[0][col-1],arr[row-1][0],arr[row-1][col-1]);
}
double findAverage(int **arr,int row,int col){
double avg;
int i,j;
int sum = 0;
for (i = 0; i < row; i++) {
      for (j = 0; j < col; j++) {
          sum = sum +data[i][j];
      }
}
avg = sum /(row*col);]
return avg;
}

int findRange(int **arr,int row,int col){
int i,j;
int min = arr[0][0];
int max = arr[0][0];
for (i = 0; i < row; i++) {
      for (j = 0; j < col; j++) {
          if(arr[i][j] < min ){
          min = arr[i][j];
          }
          else if (arr[i][j] > max ){
         max = arr[i][j];
          }
      }
}
return (max -min);

}

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