226k views
0 votes
Which XXX / YYY declare an array having 4 elements and initializes all elements with -1?

integer array (XXX) myNumbers
integer i
for i = 0; i < YYY; i = i + 1
myNumbers[i] = -1
-XXX: 4/YYY: 4
-XXX: 4/YYY: 3
-XXX: 3/YYY: 4
-XXX: 3/YYY: 3

1 Answer

3 votes

Final answer:

The correct way to declare and initialize an integer array with 4 elements to -1 is to set the array size to 4 and iterate 4 times, corresponding to option -XXX: 4/YYY: 4.

Step-by-step explanation:

The question refers to how to declare and initialize an integer array with 4 elements to the value of -1 in a generic programming context. The correct option to declare an array of 4 elements and to initialize them all with the value of -1 would be to set the size of the array to 4 and loop through the array, setting each element to -1 using a for loop that iterates 4 times. The placeholder XXX represents the size of the array, and YYY represents the number of iterations in the loop.

-XXX: 4/YYY: 4 signifies that the array should be of size 4, and the loop should iterate 4 times, which correctly matches the requirement to initialize a 4-element array.

User Beseder
by
7.4k points