Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How would I find the location of my minimum element in my 2d array? I want to show what Row and Column that the element

How would I find the location of my minimum element in my 2d array? I want to show what Row and Column that the element is at in the printf statement.

Ex: Min element is (9,4) -999

the 9 and 4 would be the row and column.

Can anyone explain it in steps?

#include #include /* srand, rand */ #include /* time */

void MaxMin (int A[10][10]){ int min, max,i,j;

min = 999; max = -99;

for (i=0;i<10;i++){ for(j=0;j<10;j++){ if (A[i][j]max){ max=A[i][j]; } } }

printf("minimum is element %d ", min); printf("Maximum is element is element %d", max); }

void SumRows (int A[10][10]){ int rows, columns, Sum, Average; Average=0;

printf(" "); for(rows = 0; rows < 10; rows++) { Sum = 0; for(columns = 0;columns < 10; columns++) { Sum = Sum + A[columns][rows]; } printf("%4d ", Sum ); Average+=Sum; } printf(" "); printf("The average is %d ", Average/100); }

int main (void) { int A[10][10];

/* initialize random seed: */ srand (time(NULL));

int i,j,a,b,c,size,location,min, max;

printf(" 1 \t2\t3\t4\t5\t6\t7\t8\t9\t10 "); //printf("1 "); for (i=0;i<10;i++){ if(i>=0){ printf("%2d ", i+1);} for(j=0;j<10;j++){ A[i][j] = rand()%1099-100; printf("%3d\t",A[i][j]); } printf(" "); } //printf("%-4d", A[1][10]); SumRows(A); MaxMin(A);

return 0; }

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 11G SQL

Authors: Joan Casteel

2nd Edition

1133947360, 978-1133947363

More Books

Students also viewed these Databases questions