#include<iostream>
using namespace std;
struct node
int data;
node*next;
};
node*head=0;
void input_at_end();
void display ();
void del();
int main(){
for(int i=1;i<=3;i++){
input_at_end();
display();
}
del();
cout<<"\nafter deleting"<<endl;
display();
}
void input_at_end(){
node*temp;
temp=new node;
cout<<"enter data";
cin>>temp->data;
temp->next=NULL;
if(head==NULL){
head=temp;
}
else{
node*temp2;
temp2=head;
while(temp2->next !=NULL){
temp2=temp2->next;
}
temp2->next=temp;
}
}
void display(){
node*temp=head;
do{
if(temp==NULL)
cout<<"end of list"<<endl;
else{
cout<<"name:"<<temp->data<<endl;
cout<<endl;
temp=temp->next;
}
}while(temp!=NULL);
}
void del(){
node*temp;
temp=head;
head=head->next;
delete temp;
}
sileshi nibret 0 Newbie Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.