added answer for  Q1,2 coding part