Question: The following program stores a list of integer numbers dynamically through a singly linked list, complete it by defining the following functions: AddNode (int): Adds

The following program stores a list of integer numbers dynamically through a singly linked list, complete it by defining the following functions: AddNode (int): Adds a new node at the beginning of the list. Traverse(): Prints the values stored in the list. float avg():Returns the average of information fields in the list.

#include using namespace std; struct node { int info; node *next; }; class sll { private: node *head; public: sll(){head=NULL;} void AddNode (int); void Traverse(); float avg(); }; void sll::AddNode (int val) {

} void sll::Traverse() {

} float sll::avg () { }

int main() { sll s; int inf, ch; while(1) { cout<<" Linked List Operations 1- Add New value to the list 2- Traverse List 3- Average of information fields in the list. 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 average of information fields in the list = "<

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!