#include
using namespace std;
int main(){
struct node{
int data;
struct nodenext;
};
int choice=1;
struct nodehead=NULL,*newnode,temp;
while(choice){
newnode=(struct node)malloc(sizeof(struct node));
cin>>newnode->data;
newnode->next=0;
if(head==0)
{
head=temp=newnode;
}
else {
newnode->next = head;
head = newnode;
}
cout<<“do you want to continue”<<endl;
cin>>choice;
}
temp=head;
while(temp!=0)
{
cout<data;
temp=temp->next;
}
}
//how to insert the following function in program
void insertatmiddle(int data, struct node*head,new node){
struct nodehead,new node;
newnode=(struct node)malloc(sizeof(struct node))
cin>>newnode->data;
newnode->next=head;
head=newnode;
}