I am unable to figure out what is wrong with my code. Kindly suggest changes to my code


Question is given in the images.

Here is my code