We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 2
‘S.No:9 Exp. Name: Write a program to insert an element in a Queue in FIFO order. Date:2023-12-06
Question description:
Sathya is an DS expert training youngsters struggling in DS to make them better He usually gives interesting
problems to the youngsters to make them love the DS.
(One such day Sathya provided to the youngsters to solve the task such that, insert an element in a Queue in
FIFO order.
Youngsters were lacking the idea to solve the problem.
Being an exciting youngster can you solve it?
Function Description:
1. Define the maximum size of queue and initialize front and rear as —1.
2. In the main function we will initialize two variables that will store the data and the size of the queue.
3, Accept the data that we want to enter in a queue using a for loop.
4. After accepting the data use enqueue() function to insert the data in a queve.
5, In this function return queue id full if the value of rear is equal to max-1
6. Else increase the value of rear by 1
7. After this insert the data that we have accepted earlier,
8, Now display the data of the queue using a disp() function.
9. In this function ifthe value of front is equal to —1 then it means list is empty.
10. Else initialize a for loop from front to rear and print the data that queue is holding.
Constraints:
(0 size
void create(int arf],int n){
int i,
for i= 4; i
+
int_main()
2023-2050-Faculty.
i
Vivekanandha College of Engineering for Women{
int n,i,ar[100];
scanf ("Kd ,8n) ;
for (i= 0; i
printf("Enqueuing %d\n",ar[0]):
create(ar,n); return 0;
for (i = 0; i