Question 5.22

Code for question 5.22 is added.