Answer:
Option 2: Reads one value and places it in the remaining first unused space endlessly.
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 <em>value </em>(Line 3).
The while loop have been defined with two conditions, 1) <em>size < capacity </em>and <em> value > 0</em>. The first condition will always be true since the size and capacity are <em>constant</em> throughout the program flow and therefore<em> size</em> 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, <em>a[3]</em>.