Write a C# program to create a Queue data structure. This Queue data structure is to store the integer values. Your program should display a menu of choices to operate the Queue data structure. See the sample menu below:
Queue Operations Menu
1. Add items
2. Delete items
3. Show the number of items
4. Show min and max items
5. Find an item
6. Print all items
Enter your choice:1
In Queue data structure, removing or adding an item is a FIFO(First In First Out) process. It allows items to be added to the end of list and removed from the beginning of the list. In this solution to the exercise, we will build a Queue data structure to store the integer values. Each item of the Queue contains two parts--data and a link. The data part is to store the integer value and the link part is a pointer to store the address of its next item. The items in the Queue are chained together by links(or pointers). We also have two important links used to point to the first item(pfirst) and point to the last item(plast) that help us in most of operations on the Queue such as adding, deleting an item, traversing through the Queue, finding an item,etc.
To keep the solution simple, we divide the solution into different steps--Defining Queue item and function prototypes, Adding item, Counting all items, Removing item, showing minimum and maximum items, searching for an item, printing items on the screen, displaying a menu of choices and the last step is to combine the C#(Csharp) code together. You can find their links in the left menu of the page.
This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages: