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

Consider the array declaration: int sales[5] = {10000, 12000, 900, 500, 20000};

ID: 3586872 • Letter: C

Question

Consider the array declaration:

int sales[5] = {10000, 12000, 900, 500, 20000};

A. the statement sales[3] = sales[3] + 10; will replace the number____

1.500 with 10

2.500 with 510

3.900 with 10

4.900 with 910

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

B. The statement sales[4] = sales[4-2]; will replace the number_____

1.500 with 498

2.20000 with 900

3.20000 with 19998

4.500 with 12000

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

C. Which of the if-statements verifies that the array subscript stored in the x variable is valid for the sales array?

1. if (x >= 0 && x<4)

2. if (x >= 0 && x <= 4)

3. if (sales[x] >= 0 && sales[x] <4)

4. if (sales[x] >= 0 && sales[x] <=4)

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

D. which of the following will correctly add the number 100 to each variable in sales array? x variable is declared as int x=0;

1. while (x<=4)

    x += 100;

2. while (x <= 4)

{   sales = sales + 100;

x +=1;

}

3. while (sales < 5)

{ sales[x] +=100;

}

4.while (x <=4)

{ sales[x] += 100;

x += 1;

}

Explanation / Answer

A ) the statement sales[3] = sales[3] + 10; will replace the number____

Ans : 4. ( 900 with 910 ) .

B. The statement sales[4] = sales[4-2]; will replace the number_____

Ans : 4. ( 500 with 12000 ) .

C. Which of the if-statements verifies that the array subscript stored in the x variable is valid for the sales array?

Ans : 4. ( if (sales[x] >= 0 && sales[x] <=4) ) .

D. which of the following will correctly add the number 100 to each variable in sales array? x variable is declared as int x=0;

Ans : 4. ( while (x <=4)

{ sales[x] += 100;

x += 1;

} ) .