My code is giving garbage value

hello @kundankumarsports2
put constructor in ur stucture in ur node .
to initilase ur node next pointer with NULL.(this is the possible cause for garbage value)

also n can be 0 as well so u need to take care of this case in ur code

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.