About the while condition

I thought of a condition, that is

fast -> next != 0 and fast -> next -> next != 0

what is the difference between this and what Prateek sir has done?

hello @udatta

to access fast->next u must make sure that fast is NOT null.
so this condition fast!=NULL is necessary.
and since we need next of next , fast->next !=NULL is also necessary

why this condition?

Why are we not take sow and fast both from head only?

you can do that as well.

Leave it. I got his one. Thanks.

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.

Not getting desired result

what input u are giving

1 2 3 4 5 -1. these are the input I am giving.

output is correct.
3-2-1 is correcct output

Actually I want to print the mid point, it should print 3.

usr cout , u are not using cout

Why print(mid) is not working?

its working

I mean how cout is printing the mid point and print(mid) is printing last 3 data

cout<data; will pritn single data only .

print is function that u have deffined that will print all nodes data till it encounter NULL.

check print function of ur code