64 669
Assignments Done
99,2%
Successfully Done
In September 2018

Answer to Question #57104 in C++ for priyam

Question #57104
write an user defined function ,the function should accept the 2D array[4][4] of integersand convert it to B[16]..
please explain the steps
Expert's answer
Solution
We must set every row side by side. So, if we look index of array, we can see that index for first row connected by low: i=>i;
for second row: i=>4+i etc.
so, in dependence form number of row, we must add corresponding number of 4.
So, we can see, that element a[i][j] corresponding to b[i*4+j].

void convertArray(int array2D[4][4], int B[16])
{
for (int i=0;i<4;i++)
for(int j=0;j<4;j++)
B[i*4+j]=array2D[i][j];
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions