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

1. What are the addresses of the following elements? a) int array[10]; and the s

ID: 3714751 • Letter: 1

Question

1. What are the addresses of the following elements?

a) int array[10];
and the starting address of the array is 48.

What is the address of the element array[2]? Give answer in decimal.

b) long array[10];
and the starting address of the array is 48.

What is the address of the element array[-1]? Give your answer in decimal.

c) short int array[10][5];
and the starting address of the array is 48.

What is the address of the element array[2][3]? Give your answer in decimal.

d) short int array[10][5];
and the starting address of the array is 48.

What is the address of the element array[9][3]? Give your answer in decimal.

e) long array [5][10];

and has a starting address at 80.

What is the address of element array[3][5]?

f)

and has a starting address at 80.

What is the value of array element array[2][16]?

Explanation / Answer

a) int array[10]; and the starting address of the array is 48. What is the address of the element array[2]? Give answer in decimal. Answer: 48 + (2*4) = 48 + 8 = 56 b) long array[10]; and the starting address of the array is 48. What is the address of the element array[-1]? Give your answer in decimal. Answer: 48 + (-1*8) = 48-8 = 40 c) short int array[10][5]; and the starting address of the array is 48. What is the address of the element array[2][3]? Give your answer in decimal. Answer: 48 + (2*5+3)*2 = 48 + 13*2 = 48 + 26 = 74 d) short int array[10][5]; and the starting address of the array is 48. What is the address of the element array[9][3]? Give your answer in decimal. Answer: 48 + (9*5+3)*2 = 48 + 48*2 = 144 e) long array [5][10]; and has a starting address at 80. What is the address of element array[3][5]? Answer: 48 + (3*10+5)*8 = 48 + 35*8 = 328 f) long array [5][10]; int k = 0; for(int i = 0; i < 5; i++) for(int j = 0; j < 10; j++) { array[i][j] = k; k++; } } and has a starting address at 80. What is the value of array element array[2][16]? value of array element array[2][16] is 36