Menu

[Solved]Include Using Namespace Std Struct Node Int Data Node Next Node Insertbegin Node Head Void Q37259297

Objectives: Implement basic functionalities using Linked Lists Question: Download Lab24.cpp. Write a menu-driven C++ program

clusers hi2suldocuments visual studio 2015Projects| Project201Debug Proje . Add a number in a particular position. . Delete

include<iostream>
using namespace std;

struct node
{
int data;
node *next;
};

node *insertBegin(node *head);
void printList(node *head);
void insertPos(node *head);
void deleteLast(node *head);
bool isEmpty(node *head);

void showMenu();

int main()
{
node *head = NULL;
int input;
while (true) {
showMenu();
cin >> input;
switch (input){

    case 1:
    head = insertBegin(head);
    break;
    case 2:
    insertPos(head);
    break;
     case 3:
    deleteLast(head);
    break;
    case 4:
        printList(head);
    break;
    case 5:
        return 0;
    default: cout << endl;
}
cout << endl;
}
return 0;
}

void showMenu() {
cout << “1. Add a number in the front.n”;
     cout << “2. Add a number in aparticular position.n”;
cout << “3. Delete the last element.n”;
cout << “4. Print list.n”;
cout << “5. Quitn”;
cout << “Please enter a choice: “;
}

bool isEmpty(node *current_head) {
node *temp;
temp = current_head;
if (temp == NULL)
return true;
return false;
}

node *insertBegin(node *current_head)
{
node* newnode = new node;
cout << “Please enter the number: “;
cin >> newnode->data;
newnode->next = current_head;
cout << “Number inserted into the list.n”;
return newnode;
}

void printList(node *head)
{
node *temp;
temp = head;
if (temp == NULL)
{
cout << endl << “The linked list is empty” <<endl;
return;
}
else
{
cout << “Linked list: “;
while (temp != NULL)
{
cout << temp->data << ” “;
temp = temp->next;
}
cout << endl;
}
}

//TO BE COMPLETED
void insertPos(node *current_head)
{

}

//TO BE COMPLETED
void deleteLast(node *head)
{

}

Objectives: Implement basic functionalities using Linked Lists Question: Download Lab24.cpp. Write a menu-driven C++ program to implement the bellow Linked Lists operations. Start your code by reading the file input.txt (download from blackboard). Insert all the values one by one to the end of the list. 1. void insertPos(node *head) Precondition: Takes the header node and prompts the user to enter two integer numbers. First number is the number that needs to be inserted. Second number is the number after which the first number will be inserted. Post-condition: Insert the first number next to the position where the second number is located. If the second number is not found in the list, a message wil1 be showed. 2. void deleteLast(node *head) Precondition: Takes the header node. ost-condition: Deletes the last number from the list. Displays a message if the list is already empty. Submit only one cpp file in this format LastName FirstName_Lab24.cpp clusers hi2suldocuments visual studio 2015Projects| Project201Debug Proje . Add a number in a particular position. . Delete the last element. . Print list. . Quit lease enter a choice: 3 inked list: 10 20 30 40 50 15 25 35 45 55 Sample Output Add a number in a particular position. Delete the last element. . Print list. . Quit lease enter a choice: 1 lease enter the number: 35 lease enter the number after which you want to insert: 36 umber inserted into the list. . Add a number in a particular position. Delete the last element. . Print list. Quit lease enter a choice: 3 inked list: 10 20 30 35 40 50 15 25 35 45 55 clusers hi2suldocumentslvisual studio 20151ProjectslProject201DebuglProject20.exe position. Add- a number in a particular position. Delete the last element. . Print list. . Quit lease enter a choice: 3 inked list: 10 20 30 40 5e 15 25 35 45 55 . Add a number in a particular position. 2. Delete the last element. B. Print list. . Quit lease enter a choice: 2 he last node has been deleted. . Add a number in a particular position, Delete the last element, . Print list. . Quit lease enter a choice: 3 inked list: 10 20 30 40 5e 15 25 35 45 Add a number in a particular position. Delete the last element. . Print list. Quit lease enter a rhoire: DOLL Show transcribed image text Objectives: Implement basic functionalities using Linked Lists Question: Download Lab24.cpp. Write a menu-driven C++ program to implement the bellow Linked Lists operations. Start your code by reading the file input.txt (download from blackboard). Insert all the values one by one to the end of the list. 1. void insertPos(node *head) Precondition: Takes the header node and prompts the user to enter two integer numbers. First number is the number that needs to be inserted. Second number is the number after which the first number will be inserted. Post-condition: Insert the first number next to the position where the second number is located. If the second number is not found in the list, a message wil1 be showed. 2. void deleteLast(node *head) Precondition: Takes the header node. ost-condition: Deletes the last number from the list. Displays a message if the list is already empty. Submit only one cpp file in this format LastName FirstName_Lab24.cpp
clusers hi2suldocuments visual studio 2015Projects| Project201Debug Proje . Add a number in a particular position. . Delete the last element. . Print list. . Quit lease enter a choice: 3 inked list: 10 20 30 40 50 15 25 35 45 55 Sample Output Add a number in a particular position. Delete the last element. . Print list. . Quit lease enter a choice: 1 lease enter the number: 35 lease enter the number after which you want to insert: 36 umber inserted into the list. . Add a number in a particular position. Delete the last element. . Print list. Quit lease enter a choice: 3 inked list: 10 20 30 35 40 50 15 25 35 45 55 clusers hi2suldocumentslvisual studio 20151ProjectslProject201DebuglProject20.exe position. Add- a number in a particular position. Delete the last element. . Print list. . Quit lease enter a choice: 3 inked list: 10 20 30 40 5e 15 25 35 45 55 . Add a number in a particular position. 2. Delete the last element. B. Print list. . Quit lease enter a choice: 2 he last node has been deleted. . Add a number in a particular position, Delete the last element, . Print list. . Quit lease enter a choice: 3 inked list: 10 20 30 40 5e 15 25 35 45 Add a number in a particular position. Delete the last element. . Print list. Quit lease enter a rhoire: DOLL

Expert Answer


Answer to include using namespace std; struct node { int data; node *next; }; node *insertBegin(node *head); void printList(node … . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *