1.8k views
19 votes
Int[] myArray1= new int[24]; int[] myArray2= new int[10]; float[] myArray3= new float[8]; int index1, index =0 for(int index1 =0; index1<24; index1++){ myArray1[inex1]=index1*2; index2=index1%10; index3=index1%8; myArray2[index2] = index3 + index 2 + myArray1[index1]; myArray3[index23 = myArray1[index2] + index3;

1 Answer

6 votes

Answer:

The value of myArray2[index2] when index1 = 12 is 30

Step-by-step explanation:

In the source code, the formula for myArray2[index2] is;

myArray2[index2] = index2 + index3 + myArray1[index1],

myArray1[index1] = index1 * 2,

index2 = index % 10 (equal to the remainder) and

index3 = index % 8

When index1 increases to 12 in the for-loop statement, the "myArray1[index1]" is equal to 24, index2 is equal to 2 and index3 is 4. The total sum is equal to 30 and assigned to "myArray2[index2]".