You are on page 1of 1

#include<iostream.h> #include<conio.

h> struct node {int info; node * link; }; node *temp; node *front=NULL; node rear=NULL; void push(); void display(); void main() {clrscr(); char ch='y'; while(ch=='y') {push(); cout<<"now the linked list is"; display(); cout<<"press y to enter again"<<"\n"; cin>>ch; } getch(); } void push() {int inf; cout<<"enter the info for new node"<<endl; cin>>inf; temp=new node; temp->info=inf; temp->link=NULL; if(front==NULL && rear==NULL) front=temp; rear=temp; else if(rear!=NULL) { rear->link=top; rear=temp; cout<<"node has been inserted"<<"\n"; } void display() { node *ttop; ttop=rear; while(ttop!=NULL) {cout<<ttop->info<<"->"; ttop=ttop->link; } cout<<"\n\n"; }

You might also like