#include<iostream>
#include<conio.h>
#include<stdlib.h>
using namespace std;
class Node
{
public:
    int info;
    Node* next;
};
class List:public Node
{
      Node *first,*last;
public:
    List()
    {
        first=NULL;
        last=NULL;
    }
    void create();
    void insert();
    void delet();
    void display();
    void search();
};
void List::create()
{
    Node *temp;
    temp=new Node;
    int n;
    cout<<"\nEnter an Element:";
    cin>>n;
    temp->info=n;
    temp->next=NULL;
    if(first==NULL)
    {
        first=temp;
        last=first;
    }
      else
    {
        last->next=temp;
        last=temp;
    }
}
void List::insert()
{
    Node *prev,*cur;
    prev=NULL;
    cur=first;
    int count=1,pos,ch,n;
    Node *temp=new Node;
    cout<<"\nEnter an Element:";
    cin>>n;
    temp->info=n;
    temp->next=NULL;
    cout<<"\nINSERT AS\n1:FIRSTNODE\n2:LASTNODE\n3:IN BETWEEN FIRST&LAST NODES";
    cout<<"\nEnter Your Choice:";
    cin>>ch;
    switch(ch)
    {
    case 1:
        temp->next=first;
        first=temp;
        break;
    case 2:
        last->next=temp;
        last=temp;
        break;
    case 3:
        cout<<"\nEnter the Position to Insert:";
        cin>>pos;
        while(count!=pos)
        {
            prev=cur;
            cur=cur->next;
            count++;
        }
        if(count==pos)
        {
            prev->next=temp;
            temp->next=cur;
        }
        else
            cout<<"\nNot Able to Insert";
        break;
      }
}
void List::delet()
{
    Node *prev=NULL,*cur=first;
    int count=1,pos,ch;
    cout<<"\nDELETE\n1:FIRSTNODE\n2:LASTNODE\n3:IN BETWEEN FIRST&LAST NODES";
    cout<<"\nEnter Your Choice:";
    cin>>ch;
    switch(ch)
    {
    case 1:
        if(first!=NULL)
        {
            cout<<"\nDeleted Element is "<info;
            first=first->next;
        }
        else
            cout<<"\nNot Able to Delete";
        break;
    case 2:
        while(cur!=last)
        {
            prev=cur;
            cur=cur->next;
        }
        if(cur==last)
        {
            cout<<"\nDeleted Element is: "<info;
            prev->next=NULL;
            last=prev;
        }
        else
            cout<<"\nNot Able to Delete";
        break;
    case 3:
        cout<<"\nEnter the Position of Deletion:";
        cin>>pos;
        while(count!=pos)
        {
            prev=cur;
            cur=cur->next;
            count++;
        }
        if(count==pos)
        {
            cout<<"\nDeleted Element is: "<info;
            prev->next=cur->next;
        }
        else
            cout<<"\nNot Able to Delete";
        break;
    }
}
void List::display()
{
    Node *temp=first;
    if(temp==NULL)
    {
        cout<<"\nList is Empty";
    }
    while(temp!=NULL)
    {
        cout<info;
        cout<<"-->";
        temp=temp->next;
    }
    cout<<"NULL";
}
void List::search()
{
    int value,pos=0;
    bool flag=false;
    if(first==NULL)
    {
        cout<<"List is Empty";
        return;
    }
    cout<<"Enter the Value to be Searched:";
    cin>>value;
    Node *temp;
    temp=first;
    while(temp!=NULL)
    {
        pos++;
        if(temp->info==value)
        {
            flag=true;
            cout<<"Element"<             return;
        }
        temp=temp->next;
    }
    if(!flag)
    {
        cout<<"Element "<     }
}
int main()
{
    List l;
    int ch;
    while(1)
    {
        cout<<"\n**** MENU ****";
        cout<<"\n1:CREATE\n2:INSERT\n3:DELETE\n4:SEARCH\n5:DISPLAY\n6:EXIT\n";
        cout<<"\nEnter Your Choice:";
        cin>>ch;
        switch(ch)
        {
        case 1:
            l.create();
            break;
        case 2:
            l.insert();
            break;
        case 3:
            l.delet();
            break;
        case 4:
            l.search();
            break;
        case 5:
            l.display();
            break;
        case 6:
            return 0;
        }
    }
    return 0;
}

Search

Project Categories

Recent Posts

Mail Management System
Posted on 2019-07-18
Online food ordering system
Posted on 2019-07-18
Library Management System
Posted on 2019-07-17
Health center system project
Posted on 2019-07-17
Gym Management System
Posted on 2019-07-17
furniture management system
Posted on 2019-07-17
Electronic shop management system
Posted on 2019-07-17
Automobile Workshop Management
Posted on 2019-07-17
Online Visa Processing System
Posted on 2019-07-17
Inventory management System
Posted on 2019-07-17
petrol-management system
Posted on 2019-07-17
Cloths management system
Posted on 2019-07-17
Society Management system
Posted on 2019-07-17
Mall management system
Posted on 2019-07-17
school management system
Posted on 2019-07-17
Sales Order Processing System
Posted on 2019-07-17
Retail sales management
Posted on 2019-07-17
Raw Materials Management
Posted on 2019-07-17
railway reservation system
Posted on 2019-07-17
purchase and sales management system
Posted on 2019-07-17
Placement Management System
Posted on 2019-07-17
Pet Shop Management System
Posted on 2019-07-17
petrol pump management system
Posted on 2019-07-17
Patient Information System
Posted on 2019-07-17
news agency system
Posted on 2019-07-17
Cinema Booking System
Posted on 2019-07-17
Medical Store System
Posted on 2019-07-17
leave management System
Posted on 2019-07-17
Laboratory Information Management System
Posted on 2019-07-17
content management system
Posted on 2019-07-17
Inventory management System
Posted on 2019-07-17
Institute Management System
Posted on 2019-07-17
Hotel management System
Posted on 2019-07-17
Gym Management System
Posted on 2019-07-17
Garage Management System
Posted on 2019-07-17
Furniture shop management system
Posted on 2019-07-17
Fisheries management  System
Posted on 2019-07-17
Fertilizer scheduling system
Posted on 2019-07-17
online eye care system
Posted on 2019-07-17
Dental Clinic Management System
Posted on 2019-07-17
Cyber Café Management
Posted on 2019-07-17
Milk Billing System
Posted on 2019-07-17
Colddrink management system
Posted on 2019-07-17
Cable management System
Posted on 2019-07-17
Beauty parlor management system
Posted on 2019-07-17
Facebook Clone
Posted on 2019-05-28
Dance Class Management System
Posted on 2019-05-24
Library Management System
Posted on 2019-05-24
Cab Management System
Posted on 2019-05-23
Blood Bank Management system
Posted on 2019-05-23
Beauty Parlour Management System
Posted on 2019-05-23
vissa proccesing system
Posted on 2019-05-23
Toll Plazza
Posted on 2019-05-23
BILLING APPLICATION
Posted on 2019-05-23
FLORICULTURE MANAGEMENT SYSTEM
Posted on 2019-05-23
Car On Rent
Posted on 2019-05-23
E-commers Shop
Posted on 2019-05-23

Sign In