Question: Given that Sale[NUM_ROW][NUM_COLUMN] is a two dimensional array of float- point type and the two constants are defined as follows: #define NUM_ROW 4 #define NUM_COLUMN

Given that Sale[NUM_ROW][NUM_COLUMN] is a two dimensional array of float-

point type and the two constants are defined as follows:

#define NUM_ROW 4

#define NUM_COLUMN 4

float Value[NUM_ROW][NUM_COLUMN] =

{

5.1, 5.2, 5.3, 5.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2,

2.1, 2.2, 2.3, 2.4

};

Write a C++ main function that computes and prints out the following information about

this 2d array:

(1) The mean of all the array elements (1.25 points).

(2) The local average values of all the array elements (1.25 points). For instance, the

local

average

value

at

position

i,

j

=

(Value[i-

1][j]+Value[i+1][j]+Value[i][j+1]+Value[i][j-1])/4. If (i+1) > NUM_ROW-1 or

(i-1) < 0, use modulus operator to wrap around to the other end of the array index.

Create another array: Average[NUM_ROW][NUM_COLUMN], and use this

array to store the values of local average at each position of this 2d array. At the

end, you need print out the values of all the array elements of Average[][] on

computer screen. Prepare a screenshot to show the values of these array elements.

Below is an image for showing how the wrap around works.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!