"menu driven program to delete in linked list" Code Answer's

You're definitely familiar with the best coding language C++ that developers use to develop their projects and they get all their queries like "menu driven program to delete in linked list" answered properly. Developers are finding an appropriate answer about menu driven program to delete in linked list related to the C++ coding language. By visiting this online portal developers get answers concerning C++ codes question like menu driven program to delete in linked list. Enter your desired code related query in the search bar and get every piece of information about C++ code related question on menu driven program to delete in linked list. 

menu driven program to delete in linked list

By ujjwal sotraujjwal sotra on May 20, 2021
#include <iostream>

using namespace std;
class node
{
public:
    int data;
    node*next;
};
node*head=NULL;
void insertlist(int val)
{
    node*temp=new node;
    temp->data=val;
    if(head==NULL)
    {
        temp->next=head;
        head=temp;
    }
    else
    {
        temp->next=head;
        head=temp;
    }
}
void delete_start()
{
    if(head==NULL)
    {
        cout<<"no element in the list :: nothing to be deleted:"<<endl;
    }
    else
    {
        node*temp=new node;
        temp=head;
        head=head->next;
        delete(temp);
    }
}
void delete_end()
{
    if(head==NULL)
    {
         cout<<"no element in the list :: nothing to be deleted:"<<endl;
    }
    else
    {
        node *temp=new node;
        temp=head;
        node*ptr=new node;
        while(temp->next->next!=NULL)
        {
            temp=temp->next;
        }
        ptr=temp->next;
        temp->next=NULL;
        delete ptr;


    }
}
void delete_any(int val)
{
    node*temp=new node;
    if(head==NULL)
    {
         cout<<"no element in the list :: nothing to be deleted:"<<endl;
    }
    else
    {
        if(head->data==val)
        {
            temp=head;
            head=head->next;
            delete temp;
        }
        else
        {
            node*ptr=new node;
            ptr=head;
            while(ptr->next!=NULL)
            {
                if(ptr->next->data==val)
                {
                    temp=ptr->next;
                    ptr->next=ptr->next->next;
                    delete temp;
                }
                ptr=ptr->next;

            }
        }
    }

}
void printf()
{
    node*temp=new node;
    temp=head;
    while(temp!=NULL)
    {
        cout<<temp->data<<" ";
        temp=temp->next;
    }
    cout<<endl;
}
int main()
{
    int n;
    int t;
    cin>>t;
    while(t--)
    {
    cout<<"enter the value to be inserted in the list:"<<endl;
    cin>>n;
    insertlist(n);
    }
    printf();
    int s;
    while(1)
    {
        cout<<"1-delete from the start"<<endl<<"2-delete from the end"<<endl<<"3-delete any element"<<endl<<"4-exit"<<endl;
        cout<<"enter your choice:"<<endl;
        cin>>s;
        switch(s)
            {
            case 1:
                {
                   delete_start();
                   printf();
                   break;
                }
            case 2:
                {
                    delete_end();
                    printf();
                    break;
                }
            case 3:
                {
                    int a;
                    printf();
                    cout<<"enter the value to be deleted:"<<endl;
                    cin>>a;
                    delete_any(a);
                    printf();
                    break;
                }
            case 4:
                {
                    exit(0);
                }
            default:
                {
                    cout<<"invalid opertaion:"<<endl;
                }
            }

    }
    return 0;
}

Add Comment

0

All those coders who are working on the C++ based application and are stuck on menu driven program to delete in linked list can get a collection of related answers to their query. Programmers need to enter their query on menu driven program to delete in linked list related to C++ code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about menu driven program to delete in linked list for the programmers working on C++ code while coding their module. Coders are also allowed to rectify already present answers of menu driven program to delete in linked list while working on the C++ language code. Developers can add up suggestions if they deem fit any other answer relating to "menu driven program to delete in linked list". Visit this developer's friendly online web community, CodeProZone, and get your queries like menu driven program to delete in linked list resolved professionally and stay updated to the latest C++ updates. 

C++ answers related to "menu driven program to delete in linked list"

View All C++ queries

C++ queries related to "menu driven program to delete in linked list"

menu driven program to delete in linked list infix to prefix using cpp linked list program linked list in c++ using class insert delete display in array c++ linked list clear cpp linked list linked list insertion in c++ circular queue using linked list in c++ linked list in c++ stl linked list operations linked list class c++ basic implementation print circular linked list c++ reverse a linked list linked list how to reverse a linked list reverse linked list Write a program to sort an array 100,200,20, 75,89.198, 345,56,34,35 using Bubble Sort. The program should be able to display total number of passes used for sorted data in given data set. c++ menu selection with arrow keys how to write int menu () function in c++ delete a head node in link list c program to add two numbers sfml base program Name one example of a “decider” program that you regularly encounter in real life. sfml basic program binary search program c++ c++ program for addition of two numbers using functions c++ calculator program using switch case program to calculate factorial of number in c++ polymorphism-program.cpp compile c++ program tower of hanoi program in c Write a program to find the sum of all sub-arrays of a given integer array. write a program to implement stack using array sfml default program c++ object program infix to postfix program in c++ if else program in c ++ run c++ program in mac terminal program to know if a number is prime running a c++ program in visual studio code cannot edit in read only editor Write a program to print following pattern; 1 1 2 1 2 3 1 2 3 4 insertion sort in c++ program c++ prime number program c++ program for matrix addition c++ program to reverse an array all pair shortest path algorithm in c with program c++ hello world program Write a program that inputs test scores of a student and display his grade cpp program to find average of n numbers how to end a c++ program early c++ input from terminal when program is called Application of c++ in youtube program c++ program to find gcd of 3 numbers c++ program to generate prime numbers run program until ctrl-d c++ Write a C++ program using class and objects. You have to define multiple-member functions outside class and all those functions will be the same name c++ program to input and print text using Dynamic Memory Allocation.loop "how we write a program for" time swap" in c plus plus only with string" fcfs preemptive scheduling program in c++ Write a c++ program to print number triangle. c ++ Program for addition of two matrix in diagonal using pointers c++ program that calculates the distance covered by a vehicle given the speed and time. how to type a vertical stack program c++ c++ program to count number of characters of words in a file using stringstream cpp program to temove space from string Write a program that inputs time in seconds and converts it into hh-mm-ss format Write a c++ program that reads a sentence (including spaces) and a word, then print out the number of occurrences of the word in the sentence write a program that simulates the rolling of two dice in c++ write a c++ program that reads ten strings and store them in array of strings, sort them and finally print the sorted strings simple program for sign in and sign up in c++ c++ program to print fibonacci series malloc c++ program set keybinding for compiling c++ program in neovim c++ program how to let the user choose different game modes Write a program to implement Liang-Bersky line clipping algorithm Create a program that finds the minimum value in these numbers bubble sort program in c++ how to run a c++ program in the background hello world program in c++ c++ how to create a program that stores details Dfs program in c++ how to make a c++ iostream program restart when finished Write a program in C++ to find post-order predecessor of a node in a Binary Tree program to swap max and min in matrix bracket balancing program in java c program to convert infix to postfix c++ delete directory excel vba delete worksheet if exists free or delete in c++ how to delete variable in c++ how to delete pointer c++ delete 2d dynamic array c++ delete from front in vector c++ c++ delete dynamically allocated array delete one specific character in string C++ delete files c++ delete memory c++ delete last char of string C++ delete in c++ how to delete something in an array c++ how to delete an element in vector pair in cpp how to delete a node c++ delete and search edge in adjacency matrix of a graph delete heap array c delete custome index from array c++ delete dynamic array c++ c++ delete printed characters new and delete operator in c++ delete an array c++ delete index from array c++ conda delete environment delete conda environment list conda environments how to print list in c++ grocery shopping list c++ chegg c++ remove multiple items from list how to make a list in c++ traverse through list c++ cpp std list example how to get an element in a list c++ list in cpp member initializer list in c++ initialization list c++ how to write C++ list c++ append to list c++ class member initializer list c++ remove item from list c++ com port list list in c++ stl c++ iterate through constant list list clear c++ list of products on e commerce websites c++ list pop back Given the following declarations below. Write a loop to read a list of numbers from the keyboard terminated by -999 and store the even numbers (skip over the odd numbers) in the vector v. clean list widget qt error: invalid use of template-name without an argument list qt widget list set selected c++ initialization list C++ drop last element of list c++ argument list for class template is missing attack on titan junior high list of episodes initializer list c++ list stl conda list environments how to show list of conda packages adjacency list representation of graph c++ list add

Browse Other Code Languages

CodeProZone