Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello I need help with a few questions on an assigment: Question 11 pts Which of

ID: 3865797 • Letter: H

Question

Hello I need help with a few questions on an assigment:

Question 11 pts

Which of the following is a true statement about the code below?

int grades[] = {100, 92, 87, 99, 100};
printIt(grades[2]);

Flag this Question

Question 21 pts

Which statement correctly declares a two-dimensional array with four rows and two columns?

Flag this Question

Question 31 pts

If an array is declared using the statements below then the index of the last element in the array is ____.

const int AA = 3;
double arrayA[AA];

Flag this Question

Question 41 pts

Assuming four bytes for an int and a column size of 4, if val is a two-dimensional int array, the array element val[1][2] is located at an offset of ____ bytes from the start of the array.

Flag this Question

Question 51 pts

When passing an array to a called function, for example printArray(arrayName); the function receives ____ array.

The number 100 is passed to the printIt function.

Explanation / Answer

Question 1: The number 87 is passed to the printIt function.

In an array, the indexing starts from 0, i.e. the first element has index 0, second element has index 1 and so on. So index 2 is actually the third element, i.e. 87.

Question 2: int temp[4][2];

The format for declaring a 2D array is <data type> <array name> [rows][columns].

Question 3: 2

The array indexes start from 0, so if an array has 3 elements, the 3rd element will have index 2.

Question 4: 24

The array is stored in a row-major form i.e. row-wise. Hence val[1][2] is the third element of the second row. Hence it has an offset of (4 elements of first row + 2 elements of second row) i.e. 6*4 = 24.

Question 5: the first element of the

When an array is passed directly to a function, the function receives a pointer to the start of the array i.e. the first element of the array.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote