Question: can someone help and explain : whenever in the code ask for the code int rows, cols; char option; /* Array definition*/ int a[MAXROWS][MAXCOLS], b[MAXROWS][MAXCOLS],

can someone help and explain : whenever in the code ask for the code

int rows, cols;

char option;

/* Array definition*/

int a[MAXROWS][MAXCOLS], b[MAXROWS][MAXCOLS], c[MAXROWS][MAXCOLS];

printf("Enter the number of rows:");

scanf("%d", &rows);

printf("Enter the number of columns:");

scanf("%d", &cols);

printf(" First Array: ");

readArrayElements(a, rows, cols);

printf(" Second Array: ");

readArrayElements(b, rows, cols);

printf("Enter your option: 'A', 'B' or 'M':");

scanf(" %c", &option);

switch (option) {

case 'A':

case 'a':

printf("Adding array 'a' and 'b' ");

addArrayElements(a, b, c, rows, cols);

printf("After adding array 'a' and 'b', the resultant array is: ");

writeArrayElements(c, rows, cols);

break;

case 'B':

case 'b':

printf("Subtracting array 'b' from array 'a' ");

subtractArrayElements(a, b, c, rows, cols);

printf("After subtracting array 'b' from array 'a', the resultant array is: ");

writeArrayElements(c, rows, cols);

break;

case 'M':

case 'm':

printf("Multiplying array 'a' with array 'b' ");

multiplyArrayElements(a, b, c, rows, cols);

printf("After multiplying array 'a' with array 'b', the resultant array is: ");

writeArrayElements(c, rows, cols);

break;

default:

printf("Invalid input ");

}

return 0;

}

void readArrayElements(int a[][MAXCOLS], int nRows, int nCols){

int i, j;

for ( i = 0; i < nRows; i++){

printf("Enter data for row no: %d ", i);

for ( j = 0; j < nCols; j++){

scanf("%d", &a[i][j]);

}

}

return;

}

//Print the array 'a'

void writeArrayElements(int a[][MAXCOLS], int nRows, int nCols){

// insert your code here!( 4pts)

}

// Add array 'a' with array 'b'

void addArrayElements(int a[][MAXCOLS], int b[][MAXCOLS], int c[][MAXCOLS], int nRows, int nCols){

// insert your code here! ( 2 pts)

}

// Subtract array 'b' from array 'a'

void subtractArrayElements(int a[][MAXCOLS], int b[][MAXCOLS], int c[][MAXCOLS], int nRows, int nCols){

// insert your code here! ( 2 pts)

}

// Multiply array 'a' with array 'b'

void multiplyArrayElements(int a[][MAXCOLS], int b[][MAXCOLS], int c[][MAXCOLS], int nRows, int nCols){

// insert your code here! ( 2 pts)

}

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!