# Thread: Convert a two-dimensional array to a one demensional array

1. right it should be
Code:
```fint i, j, k;
int power1d[56];

for(i = 0; i<NROWS; i++)
{
for(j=0; j<NCOLS; j++)
{
for(k=0; k <56; k++)
power1d[k] = power[i][j];
}}```

2. i fixed the power1d

3. Closer. You just have to decide what k is going to be. Currently you are assigning each element of power into every element of power1d, which means only the last element is the one you get kept. You're already in the for loop, so you're looking at one specific element of the power array -- now where does that one specific element need to go?

4. Yea i knew something was wrong because when i printed it out it was a mess, so does k need to be an outside loop?

5. k shouldn't be a loop at all. k needs to be computed based on i and j.

6. so k should be
k=(i +1) *(j+1) - 1
????

7. i dont think this is the right equation? it works for the first seven then messes up on the index, but the value of the index is correct, do you know of an equation that would fix this?

8. figured it out
k=(i*7)+j;

9. Originally Posted by belkins
figured it out
k=(i*7)+j;
bingo!

10. Look at code that I have posted. I have given many examples of how to do this.