Please tell me where I am going wrong

In if condition of line 11, after assigning value of c=1 , add break.
In line 17, while condition should be fast->next != slow->next
Also add a base case at the starting of the function that what if head==null or head->next == null.