7.8- Two-Dimensional Arrays & 7.9- Arrays with Three or More Dimension

Your page rank:

Total word count: 572
Pages: 2

Calculate the Price

- -
275 words
Looking for Expert Opinion?
Let us have a look at your work and suggest how to improve it!
Get a Consultant

Declare a 8×8 two-dimensional array of strings named chessboard.

string chessboard[8][8];

Declare a 3×3 two-dimensional array of integers named tictactoe.

int tictactoe[3][3];

Declare a two-dimensional array of integers named arr with 3 rows and 10 columns.

int arr[3][10];

Given a two-dimensional array x of doubles , write an expression whose value is twice the value of the element in the 3rd row and the 2nd column.

x[2][1] * 2

Given a two-dimensional array x of element type int , write an expression whose value is the sum of the element in the 3rd row/4th column and the element in the 5th row/1st column.

x[2][3] + x[4][0]

Given a two-dimensional array x of element type int with 5 rows and 4 columns, write an expression whose value the last element in the array (the last column of the last row).

x[4][3]

Given a two-dimensional array x of element type double , and two integer variables i and j, write an expression whose value is the i-th element in the j-th row.

x [i][j]

Given a two-dimensional array of integers named q, with 2 rows and 4 columns, write some code that puts a zero in every element of q. Declare any variables needed to help you.

for (int i = 0; i < 2; i++) { for (int j = 0; j < 4; j++) q[i][j] = 0 ; }

you are given a 6×8 (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.

max = x[0][0]; for(i = 0; i < 6; i++){ for(j = 0; j < 8; j++){ if(x[i][j] > max ) max = x[i][j]; } }

Given two 2×3 (2 rows, 3 columns) arrays of integer , x1 and x2, both already initialized , two integer variables , i and j, and a boolean variable x1Rules. Write the code that is necessary for x1Rules to be true if and only if every element in x1 is bigger than its corresponding element in x2 and is false otherwise

Declare an array of integers , westboundHollandTunnelTraffic that can store the number of vehicles going westbound through the Holland Tunnel on a particular hour (numbered 0 through 23) on a particular day (numbered 0 through 6) on a particular week numbered (0 through 51) over the last ten years (numbered 0 through 9). The innermost dimension should be years, with the next being weeks, and so on.

int westboundHollandTunnelTraffic [10] [52] [7] [24];

Again, consider the testPIN function used in Program 7-21. For convenience, we have reproduced the code for you below.

Rewrite the function body of this function so that instead of using iterating through the elements of the parallel arrays , it returns true or false by calling countMatches the function defined in the previous exercise (10988), and checking its return value .

bool testPIN(int custPIN[], int databasePIN[], int size) { for (int index = 0; index < size; index++) { if (custPIN[index] != databasePIN[index]) return false; // We’ve found two different values. } return true; // If we make it this far, the values are the same. }

Given two 2×3 (2 rows, 3 columns) arrays of integer , x1 and x2, both already initialized , two integer variables , i and j, and a boolean variable x1Rules. Write the code that is necessary for x1Rules to be true if and only if every element in x1 is bigger than its corresponding element in x2 and is false otherwise

for(int i=0;i<2 ;i++) { for( int j=0;j<3 ;j++) { if(x1[i][j] > x2[i][j]) { x1Rules = true;} else { x1Rules = false;} } }

Share This
Flashcard

More flashcards like this

NCLEX 10000 Integumentary Disorders

When assessing a client with partial-thickness burns over 60% of the body, which finding should the nurse report immediately? a) ...

Read more

NCLEX 300-NEURO

A client with amyotrophic lateral sclerosis (ALS) tells the nurse, "Sometimes I feel so frustrated. I can’t do anything without ...

Read more

NASM Flashcards

Which of the following is the process of getting oxygen from the environment to the tissues of the body? Diffusion ...

Read more

Unfinished tasks keep piling up?

Let us complete them for you. Quickly and professionally.

Check Price

Successful message
sending