# Thread: Very easy task with arrays, but a cannot do it

1. ## Very easy task with arrays, but a cannot do it

It's a very easy task, but for some reason I cannot do it, I'm trying to do it for many hours already, help me please.

Make a function that has as its parameters length of 2 arrays and these 2 arrays too. It needs to assign all nonzero values from 1st array to 2nd, from left to right in ascending order and return number of significant ( that were assigned to 1st to 2nd ) elements of 2nd array.
Prototype:
Code:
`size_t counter(size_t length, int input[length], int output[length]);`
If it was not understandable I'll give an example.
Code:
```input {1, 4, 0, -6, 0} --> output {-6, 1, 4, trash, trash}
return 3```

2. Show us the code you have tried already, for instance, you probably went with a loop of some kind.

3. The problem that, is I'm stuck on assigning elements from 1st do 2nd, I just cannot figure out how to do it normally, without very long and hard methods

4. > It needs to assign all nonzero values from 1st array to 2nd, from left to right in ascending order and
> return number of significant ( that were assigned to 1st to 2nd ) elements of 2nd array.
So ignore "ascending order" for the moment, and see if you can get as far as say
Code:
```input {1, 4, 0, -6, 0} --> output {1, 4, -6 }
return 3```
Learning how to break down problems into more manageable steps is just as valuable skill as knowing where the curly braces go.

Perhaps more important; if you can only solve problems which are immediately obvious and coded in a single keyboard session, you're not going far.

5. Originally Posted by Salem
>
So ignore "ascending order" for the moment, and see if you can get as far as say
I already tried to copy elements from 1st to 2nd, and succesfully done it, but because of trash elements i am not able to do normal sorting

6. I've just finally managed to do it, solving was so close that I needed to add less than 15 symbols, thanks everyone.