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.

Answer :

Answer:

The code is mentioned below.

Explanation:

This code is written in C.

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

[tex] x[6][8] [/tex]

which will be called or referred in program by:

[tex] x [i] [j] [/tex]

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.

Other Questions