Answer:
Option 2: Reads one value and places it in the remaining first unused space endlessly.
Step-by-step explanation:
Given the code as follows:
- int[] a = {1, 3, 7, 0, 0, 0};
- int size = 3, capacity = 6;
- int value = cin.nextInt();
- while (size < capacity && value > 0)
- {
- a[size] = value;
- }
The a is an array with 6 elements (Line 1). The program will prompt the user for an integer and assign it to variable value (Line 3).
The while loop have been defined with two conditions, 1) size < capacity and value > 0. The first condition will always be true since the size and capacity are constant throughout the program flow and therefore size will always smaller than capacity.
Hence, if user input an integer larger than 0, the while loop will infinitely place the same input value to the remaining first unused space of the array, a[3].