Regarding the error

I am not getting any output !!!

Hello @gargshivam2001 please wait i am checking till then can you please explain your logic here.


sir ,
i have updated my code and mentioned my logic in comments !!!
please correct the code

@gargshivam2001 dnt fill the ‘out’ string with indexing:
please see this code:
i have implemented it according to your logic:


if you have any doubt you can ask here:
Happy Learning!!

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.

why we don’t have to fill out string with indexing ???
if so, why we have been accessing input string with indexing ???
how this could be possible one is working with indexes , other not ???

Hello @gargshivam2001 the other will also work with indexes but the difference is that then you have to take another loop for that.
it is just the syntax that you have to understand you and me cannot do anything in this.

You can see the code even the string which we are taking in input for the number is without indexing.


what about this , I have find it at your doubt portal and it is working well ???

@gargshivam2001 what i am doing is just appending to the last.
it is more easier and faster then the indexing.

@gargshivam2001 yes i am saying that you can do with indexing as well but you have to decide that either you have to tally by indexing or totally by appending.
you can make use of both the methods simultaneously.

sir, both codes are exactly same ,one is getting output , other not ,why???


@gargshivam2001 no both the codes are not same.
do you know the difference between the character array and the string.
if you will also use the character array then your code will also work fine.


check the above code of yours with the character array.
please dont merge everything try to implement and understand yourself as well.
try to the dry run.
Happy Learning!!

Ok !! thank you sir !!

@gargshivam2001 i am marking this doubt as resolved now.
Happy Learning!!

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.