Question 22 The first element in a twodimensional array has

Question 22

The first element in a two-dimensional array has a row subscript of __________ and a column subscript of __________.

0, 0

0, 1

1, 0

1, 1

-----------------------------------

Question 23

The sales [4] = sales[4 - 2]; statement will __________.

Use the following 5 element array, named sales, to answer this question.  

10000

12000

900

500

20000

replace the 20000 amount with 900

replace the 20000 amount with 19998

replace the 500 amount with 12000

result in an error

-----------------------------------

Question 24

The sales[3] = sales[3] + 10; statement will __________.

Use the following 5 element array named sales to answer the question.

10000

12000

900

500

20000

replace the 500 amount with 10

replace the 500 amount with 510

replace the 900 amount with 910

result in an error

0, 0

0, 1

1, 0

1, 1

Solution

Question 22:

In a p x q two dimensional array, there are p rows and q columns.

Row indexing starts from 0 to p-1

Column indexing starts from 0 to q-1

The first element in a two dimensional array has a row subscript of 0 and a column subscript of 0.

Hence the correct option is 0, 0

___________________________________________________________________________________________________________

Question 23:

Array sales is a 5 element array with elements {10000, 12000, 900, 500, 20000}.


Values based on index values:

sales[0] = 10000, sales[1] = 12000, sales[2] = 900, sales[3] = 500, sales[4] = 20000

sales[4] holds the value 20000
sales[4-2] = sales[2] holds the value 900.

Statement sales[4] = sales[4 - 2] replaces the value(20000) present at index 4 with value(900) present at index 2 of sales array.

After executing the statement, values in the array sales: {10000, 12000, 900, 500, 900}

Hence the correct option is   - replace the 20000 amount with 900.

___________________________________________________________________________________________________________

Question 24:

Array sales is a 5 element array with elements {10000, 12000, 900, 500, 20000}.


Values based on index values:

sales[0] = 10000, sales[1] = 12000, sales[2] = 900, sales[3] = 500, sales[4] = 20000

sales[3] holds the value 500

Statement sales[3] = sales[3] + 10 will replace the value(500) present at index 3 with value 510(500 + 10).

After executing the statement, values in the array sales: {10000, 12000, 900, 510, 20000}

Hence the correct option is - replace the 500 amount with 510.

Question 22 The first element in a two-dimensional array has a row subscript of __________ and a column subscript of __________. 0, 0 0, 1 1, 0 1, 1 -----------
Question 22 The first element in a two-dimensional array has a row subscript of __________ and a column subscript of __________. 0, 0 0, 1 1, 0 1, 1 -----------

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site