A queue is a restricted data structure that allows only the following operations:
a.Enqueue" an item at the end" of the queue.
b.Dequeue" an item from the beginning" of the queue.

These should correlate with your intuitive notion of a queue (line) in the physical world. In queues the first element added to the queue will be the first one to be removed, i.e. elements are removed in the same order they were entered.
Note that there is no means of direct access to items that aren't on beginning or end of the queue.

Create a class queue with integer attribute count which represents the number of elements in the queue and a char array data of 100 elements where elements of the queue are actually saved.

Provide a constructor function that initialize the of elements in the array to zero and two member functions: function void enqueue (char) and function char dequeue (). The first is used to insert a character to the queue and the second to remove a character from the queue.

You must separate the interface from the implementation. Write a main function to test your class
See the sample output below

the Sample out put is just like that :

Welcome to My Queue Program

Please enter 1 to enqueue, 2 to dequeue an element, 3 to print the queue, 4 to exist the program?
2
Sorry there are no elements in the queue

Please enter 1 to enqueue, 2 to dequeue an element, 3 to print the queue, 4 to exist the program?
1
Enter a character: C

Please enter 1 to enqueue, 2 to dequeue an element, 3 to print the queue, 4 to exist the program?
1
Enter a character: F

Please enter 1 to enqueue, 2 to dequeue an element, 3 to print the queue, 4 to exist the program?
1
Enter a character: T

Please enter 1 to enqueue, 2 to dequeue an element, 3 to print the queue, 4 to exist the program?
3
Your queue is C F T

Please enter 1 to enqueue, 2 to dequeue an element, 3 to print the queue, 4 to exist the program?
2
C has been removed from your queue

Please enter 1 to enqueue, 2 to dequeue an element, 3 to print the queue, 4 to exist the program?
3
Your queue is F T

Please enter 1 to enqueue, 2 to dequeue an element, 3 to print the queue, 4 to exist the program?
4

Thanks for using the queue program

Recommended Answers

All 3 Replies

Hey, I have an idea! How about you do your own homework instead of asking other people to help you cheat?

commented: tebeda +0

$500 in 20 minutes. Deal??

take the value of cost price and selling price of a particular item from user and print if it profit or loss and how much

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.