0
#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;
    }
2
Contributors
1
Reply
10
Views
3 Years
Discussion Span
Last Post by Ancient Dragon
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.