Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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, the sum of each row, and the sum of each column.

Here is a sample output: When input is 5 3 2.0 2.0 for X Y minZ maxZ Standard output starts with Overall sum = 30.0

Sum of each row

Row0 = 6.0

Row1 = 6.0

Row2 = 6.0

Row3 = 6.0

Row4 = 6.0

Sum of each column

10.0 10.0 10.0

#include #include

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; } /* Dont forget to include comments about the problem, yourself and each major step in your program! */

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Solaris 11.2 System Administration (oracle Press)

Authors: Harry Foxwell

1st Edition

007184421X, 9780071844215

More Books

Students also viewed these Databases questions

Question

Describe the characteristics of a 360-degree performance appraisal.

Answered: 1 week ago

Question

4. What action should Cherita Howard take and why?

Answered: 1 week ago