Write a C++ program to solve each problem below.
1. Create an element structure and a list structure that can store a list of integer numbers. Create 4 functions to i) Create an empty list, ii) Add a number to begin of list, iii) Add a number to end of list, iv) Add a number to specific position in the list, and v) display list. Put all of these structures and functions into a header file named: yourName-SingleLinkList.h
Hint: Following are sample function prototypes:
List* createAnEmptyList( ) void addToBeginOfList(List *ls, int data)
void displayList(List *ls) void addToEndOfList(List *ls, int data)
void addSpecificPositionInList(List *ls, int data, int position)
2. Get a number n from a user. Include the user-defined header, yourName-SingleLinkList.h, created from problem #1. Build a singly linked list to store all numbers from 1 to n. Display all data in the list.
Comments
Leave a comment