Code for this question please

I am unable to write the code