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

can it be in programming language C, thanks! /* * You can copy and modify the be

ID: 3744951 • Letter: C

Question


can it be in programming language C, thanks!

/*
* You can copy and modify the below code
*/
#include <stdio.h>
#include <stdlib.h>
/* this function returns a random number between [low, high] *
double RandomReal(double low, double high){
double d;
d = (double) rand() / ((double) RAND_MAX + 1);
return (low + d * (high - low));
}
int main(int argc, char* argv[]) {
int X, Y;
double minZ, maxZ;
double **Arr2D;
printf("Enter X Y minZ maxZ:");
scanf("%d %d %lf %lf", &X, &Y, &minZ, &maxZ);

/* dynamically create 2D array of doubles (X row, Y col),
* For each i, j
* if (minZ == maxZ) Arr2D[i][j] = minZ;
* else Arr2D[i][j] = RandomReal(minZ, maxZ);
* Then find the sums we want using the given Arr2D !
*/
/* YOUR CODE */
return 0;
}

Write a program that ask user to enter two integers X and Y, and two doubles minZ maxZ. It then allocates a dynamic 2D array consisting of X rows and Y columns of double values, and sets each value in the 2D array by randomly generating a number between minZ and maxZ. If (minZ- maxZ), then simply set each value in the 2D array to minZ. Then print the overall sum of all the values in the whole 2D array, the sum of each row, and the sum of each column. Here is a sample output When the input is for X Y minZ maxZ Your output should be as follows Overall sum30.0 Sum of each row Row06.0 Rowl6.0 Row26.0 Row3 = 6.0 Row46.0 sum of each c 1umn 10.0 10.0 10.0 At the end we provide the template and a function to generate random numbers. Copy that program and modify it...

Explanation / Answer

/* * You can copy and modify the below code */ #include #include /* this function returns a random number between [low, high] */ double RandomReal(double low, double high){ double d; d = (double) rand() / ((double) RAND_MAX + 1); return (low + d * (high - low)); } int main(int argc, char* argv[]) { int X, Y; double minZ, maxZ; double **Arr2D; printf("Enter X Y minZ maxZ:"); scanf("%d %d %lf %lf", &X, &Y, &minZ, &maxZ); /* dynamically create 2D array of doubles (X row, Y col), * For each i, j * if (minZ == maxZ) Arr2D[i][j] = minZ; * else Arr2D[i][j] = RandomReal(minZ, maxZ); * Then find the sums we want using the given Arr2D ! */ /* YOUR CODE */ int i=0, j=0; Arr2D = (double **)malloc(sizeof(double *)*X); double sum = 0; for(i = 0; i
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