#include<iostream>
using namespace std;
struct node
{
int data;
struct node *next;
};
struct node *p=NULL;
int main()
{
struct node *head,*temp;
int i,n;
cout<<"Enter no. of nodes";
cin>>n;
head=p;
head=(struct node*)malloc(sizeof(struct node));
cout<<"\nEnter data of first node ";
cin>>head->data;
head->next=NULL;
temp=head;
for(i=0;i<n;i++)
{
temp=(struct node*)malloc(sizeof(struct node));
cout<<"\nEnter data";
cin>>temp->data;
temp->next=NULL;
temp=temp->next;
}
temp=head;
while(temp->next!=NULL)
{
cout<<"\t"<<temp->data;
temp=temp->next;
}
return 0;
}