solution using the iterative structure do