What wrong in my code

#include
using namespace std;
struct node{
long long int data;
struct node *next;
};
struct node *p,*s;
void addtrail(node &head,long long int data){
node
n=new node;
n->data=data;
n->next=NULL;
if(head==NULL){

head=n;
p=n;
}
p->next=n;
p=n;

}
void kalternate(node *&head){
node *p=head;
node *q=head->next->next;
while(p!=NULL&&q!=NULL&&q->next!=NULL){
if(p==q){
break;
}
p=p->next;
q=q->next->next;
}
p=head;
while(p!=NULL&&q!=NULL){
if(p==q){
break;
}
p=p->next;
q=q->next;
}
node r=p;
while(p->next!=r){
p=p->next;
}
p->next=NULL;
}
int main() {
int k;
node
head=NULL;
int data;
cin>>data;
while(data!=-1){
addtrail(head,data);
cin>>data;
}
kalternate(head);
node *t=head;
while(t){
cout<data;
t=t->next;

}

return 0;

}

@dineshjani I think you are trying to use slow fast pointer but u need to understand that you cannot use it here beacuse question says you are using circular link list but actually you are using single link list there is no node in you linklist connecting to its one of the link list node so there is no loop here so slow fast pointer will terminate at one place instead of iterating again and again in loop.

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.