why this is showing a run error
here is the code:-
#include
using namespace std;
class node
{
public:
int data;
node *link;
node(int d)
{
data=d;
link=NULL;
}
};
bool pall(node *head,node *head1)
{
while(head!=NULL)
{
if(head->data!=head1->data)
{
return false;
}
head=head->link;
head1=head1->link;
}
return true;
}// end of pall
node *reverse(node *head)
{
node *cur=head;
node *prev=NULL;
node *next=head->link;
while(cur!=NULL)
{
cur->link=prev;
prev=cur;
cur=next;
next=next->link;
}
head=prev;
return head;
}
void insert_last(node *&head,int d)
{
if(head==NULL)
{
head=new node(d);
return;
}
node *wand=head;
while(wand->link!=NULL)
{
wand=wand->link;
}
wand->link=new node(d);
return;
}
void printlist(node *head)
{
while(head !=NULL)
{
cout<data<<" ";
head=head->link;
}
}
void makelist(node *&head,int n)
{
int d;
while(n–)
{
cin>>d;
insert_last(head,d);
}
}
//end of makelist
int main()
{
node* head=NULL;
int n;
cin>>n;
makelist(head,n);
printlist(head);
node *head1=reverse(head);
cout<<endl;
printlist(head1);
if(pall(head,head1))
{
cout<<“True”<<endl;
}
else
cout<<“False”;
return 0;
}