Just a note in C usually the variables are on top so you could get rid of "int k" and put it as "k" and then declare k as part of your list of ints at the top.