After the following code executes the values in the array ar

After the following code executes, the values in the array are __________ , _______ , ___________   (numeric values).

Solution

Answer:

The values in the array are 0 , 1 , 2

int v[] = new int[3]; will create an array of length 3. But the elements of the array is denoted by v[0], v[1], and v[2].

And they will all have a value of zero initially. In the for loop, you will see i=1, means i starts from 1, and ends at 2. So, the equation is basically saying v[1] = v[0] + 1 which is 0+1 = 1 , and v[2] = v[1] + 1 which is 1 + 1 = 2

After the following code executes, the values in the array are __________ , _______ , ___________ (numeric values).SolutionAnswer: The values in the array are 0

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site