Question: The following C program creates an two-dimensional array of integers of size 40 by 50 where each cell at row index i and column index

The following C program creates an two-dimensional array of integers of size 40 by 50 where each cell at row index i and column index j stores the value of ((i+1)*(j+1)):

#include

void main(void){

int array[40][50];

for(int i = 0; i < 40; i++)

for(int j = 0; j < 50; j++)

array[i][j] = (i+1) * (j+1);

printf("%d", your_function(array));

}

1. Write a function that receives the 2D array as its only input parameter, traverses all cells of the array, counts the number of elements in the array that are divisible by 6 but are not divisible by 5 (e.g. 6, 18 are counted, but 30 or 60 are not counted), and finally returns the total count.

2. Can you make the function find the total count in a more efficient way? How?

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!