The code of problem C