How can i solve this question?

Please tell whether my approach is wrong if not so,what’s the problem in my code it is not executing?