What is wrong in my code?

hi @aakshatmalhotra100
there were 2 mistakes-

  1. u were not giving a newline after each test case… so just put a endl statement after printing the ans
  2. u had written return 0 inside the while loop, that’s why code was not running on all test cases… so just move that statement out of while loop…

corrected code, it is passing all test cases now–>

Thanks I did some silly mistakes

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.