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;
}
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; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.