Menu
support@nursinghomework.org
+1 714-215-3097

(Solved) : Would Find Location Minimum Element 2d Array Want Show Row Column Element Printf Statement Q35571681

How would I find the location of my minimum element in my 2darray? I want to show what Row and Column that the element is at inthe 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 <stdio.h>
#include <stdlib.h> /* srand, rand */
#include <time.h> /* 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]<min){
min=A[i][j];
}
}
}
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 %dn”, min);
printf(“Maximum is element is element %d”, max);
}

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

printf(“n”);
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(“nn”);
printf(“The average is %d n”, 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 t2t3t4t5t6t7t8t9t10n”);
//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(“%3dt”,A[i][j]);
  
}
printf(“n”);
}
  
//printf(“%-4d”, A[1][10]);
SumRows(A);
MaxMin(A);

return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *