Insert at tail...... i didn't get an output . see my code

#include
using namespace std;

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

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

};

void insertattail(node*&head,int data)
{
if(head==NULL)
{
head=new node(data);
return;
}
node*tail=head;
while(tail->next!=head)
{
tail=tail->next;
}
tail->next=new node(data);
return;
}

void input(node*&head)
{
int d;
cin>>d;
while(d!=-1)
{
insertattail(head,d);
cin>>d;
}
}

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

int main()
{
node*head=NULL;
input(head);
print(head);
return 0;
}

Hi @sagarsambisla

There were some minor errors. I have corrected them for you.

Link : https://ide.codingblocks.com/s/200501

Hope it Helps.

Also, from next time save your code on ide then share the link.

@sagarsambisla
Please mark your doubt as solved.