Can you pls check the code why output is coming wrong

resolved got my mistake):