NO CLUE FOR MY RUN TIME ERROR

why is it giving runtime error, plz help debugging

#include
using namespace std;

class node{
public:
int data;
node* next;

	node(int key){
		data = key;
		next= NULL;
	}

};

void input(node*&head , int key){
if(head == NULL){
head = new node(key);
}
else{
node * emp = head;
while(emp -> next != NULL){
emp = emp ->next;
}
node * temp = new node(key);
emp->next = temp;
}
return;
}

void print (node * head){
while(head!=NULL){
cout<<head ->data<<" ";
head = head->next;
}
}

int main(){
node* head = NULL;
int len;
cin>>len;
for(int i=0;i<len;i++){
int key;
cin>>key;
input(head,key);
}
int end;
cin>>end;
nodeslow = head;
node
fast = head;
while(end–){
slow = slow->next;
fast = fast->next->next;
}
while(fast!=NULL && fast->next != NULL){
fast=fast->next;
slow=slow->next;
}
node* temp = slow->next;
node* head2 = temp;
slow->next = NULL;
while(temp->next != NULL){
temp = temp->next;
}
temp->next = head;
print(head2);

return 0;

}

Hey @saurabh66
Please share your code in Coding Blocks IDE :slight_smile:

Hey @saurabh66
Updated ur code and mentioned the changes in comments : https://ide.codingblocks.com/s/351421

thank you so much!!!

1 Like

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.