Getting wrong output


please correct my code and tell me why my approach is incorrect

Hey i have mentioned it in comment.Sorry last time i forgot to add the link