Answered! 6. Consider the following declarations: const int CAR_TYPES = 5;…

6. Consider the following declarations:

const int CAR_TYPES = 5;

const int COLOR_TYPES = 6;

double sales[CAR_TYPES][COLOR_TYPES];

a. How many components does the array sales have?

b. What is the number of rows in the array sales?

c. What is the number of columns in the array sales?

d. To sum the sales by CAR_TYPES, what kind of processing is required?

e. To sum the sales by COLOR_TYPES, what kind of processing is required?

7. Suppose that you have the following declarations:

int times[30][7];

int speed[15][7];

int trees[100][7];

int students[50][7];

a. Write the definition of the function print that can be used to output the contents of

these arrays.

b. Write the C++ statements that calls the function print to output the contents of the

arrays times, speed, trees, and students.

Expert Answer

 Q6-

a-array sales can have 30 elements in it as we have CAR_TYPES=5 and COLOR_TYPES=6 so array will have 5*6=30 elements.
b-Number of rows in array sales are 5
c- Number of coloumns in array sales 6.
d-to sum the sales by CAR-TYPES we can add the elements of each row so it can show sales for each type of car.
e- to sum the sales by COLOUR_TYPES we can add the elements of each coloumn so we can have sum by COLOR_TYPES.

Q7-
a-
void print(arr[][],m,n)
{
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
cout<<arr[i][j]
}
cout<<“n”;
}

b-
print(times,30,7);
print(speed,15,7);
print(trees,100,7);
print(students,50,7);

Still stressed from student homework?
Get quality assistance from academic writers!