getting wrong answer

i am not able to figure out the reason for a wrong answer. The program is logically correct but still it produces a wrong answer and I am not able to understand why this is happening please somebody help