8.9k views
0 votes
Asume that an array of ints named a that contains exactly five elements has been declared and initialized. In addition, an int variable j has also been declared and initialized to a value somewhere between 0 and 3. Write a single statement that assigns a new value to element of the array indexed by j. This new value should be equal to twice the value stored in the next element of the array (i.e. the element after the element indexed by j.

User Sirrah
by
4.9k points

1 Answer

1 vote

Answer:

a [ j ] = 2 * a [ j + 1 ];

Step-by-step explanation:

For an element at index j, the next element is at index j+1.

Therefore, given an array a, to initialize the element at index j to twice the value of the next element, the statement is as follows:

a [ j ] = 2 * a [j + 1]

or

a [ j ] = a [j + 1] * 2

Hope this helps!!

User SERPRO
by
5.4k points