This is the code for the algorithm in task c), in this code the algorithm is generalized so that we usa the arrays for a and c as in the text.