One problem you have here is that you have not initialised the ' i ' variable, this means [0][i] refers to an unknowable value, as a general rule remember to 'zero your ints'