Given 2 int arrays, a and b, each length 3, form a new array of length 2, containing their middle elements.
Answers
Answered by
2
Answer:
There are many approach to solve this question. the simplest answer would be to create a new array c by assigning the middle elements of array a and b.
Explanation:
The following sudo code explains the solution. array elements can be accessed by specifying the index and array index always starts from 0. since the number of elements are known i.e. 3. we can easily find the middle elements by specifying index 1.
// let's define the two int arrays
int a =[5,8,9]
int b =[8,6,5]
//Blank array
int c =[]
// array index starts from 0
c[0] = a[1]
c[1] = b[1]
Similar questions