There is your problem. It should be iA < n. I am guessing you originally intended iA != n, but it ended up being a typo. The reason why that loop never terminates is because that assignment is...