14.5k views
2 votes
You are given a 6x8 (6 rows, 8 columns) array of integers, x, already initialized and three integer variables: max, i and j. Write the necessary code so that max will have the largest value in the array x.

1 Answer

6 votes

Answer:

The code is mentioned below.

Step-by-step explanation:

This code is written in C.

Assuming that an array of 6 by 8 is already initialized and stored in a vector


x[6][8]

which will be called or referred in program by:


x [i] [j]

Alongwith the array the variables i j and max will be initialized as integers.

CODE:

int i,j,max;

max=0;

for(i=0;i<6;i++)

{

for(j=0;j<6;j++)

{

if(max>x[i][j])

max = x[i][j];

}

}

This code will check each and every entry of 6 by 8 array and place the largest value in max.

User Anas Azeem
by
8.6k points