Question: USING C++ The following program stores a list of integer numbers dynamically through a singly linked list, complete it by defining the following functions: 1-
USING C++
The following program stores a list of integer numbers dynamically through a singly linked list, complete it by defining the following functions:
1- AddNode (int): Adds a new node at the end of the list.
2- Traverse(): Prints the values stored in the list.
3- int deleteAfterValue(int): deletes the node after a given node value , then return the Deleted value.
#include
using namespace std;
struct node
{
int info;
node *next;
};
class sll
{
private:
node *head;
public:
sll(){head=NULL;}
void AddNode (int);
void Traverse();
int deleteAfterValue();
};
void sll::AddNode (int val)
{
}
void sll::Traverse()
{
}
int sll:: deleteAfterValue()
{
}
int main()
{
sll s;
int inf, ch;
while(1)
{
cout<<" Linked List Operations 1- Add New value to the list 2- Traverse List 3- Count the number of even numbers 4- Exit Your Choice: ";
cin>>ch;
switch(ch)
{
case 1:
cout<<" Put info/value to Add: ";
cin>>inf;
s.AddNode(inf);
break;
case 2:cout<<" Linked List Values: ";
s.Traverse();
break;
case 3:
cout<<"The number of deleted values in the list = "<
break;
default: exit(0);
}
}
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
