The declarations at the top of the function, that is just a requirement by my teacher.

As for the y[j++], I wanted it to do what you rewrote the code to do.

Thanks for your help so far I will try to rewrite the code and repost it if i'm still having trouble.