Same code but wrong output

i have written same code as prateek bhaiya
but output is not as expected


added comments