QUEUE IMPLEMENTATION USING ARRAY
BCA third semester
DATA STRUCTURE
#include<stdio.h> #include<conio.h> #include<stdlib.h> #define max 5 int front=0,rear=-1; int queue[max]; void main() { int ch,i; while(1) { clrscr(); printf("1. Insertion\n2. Deletion\n3. Display\n4. Exit\n\nEnter your Choice : "); scanf("%d",&ch); switch(ch) { case 1: clrscr(); if(rear == max-1) printf("Queue Overflow !!!!"); else { rear++; printf("Enter Element : "); scanf("%d",&queue[rear]); } getch(); break; case 2: clrscr(); if(front>rear) printf("Queue Underflow !!!!"); else { printf("%d is deletion element",queue[front]); front++; } getch(); break; case 3: clrscr(); if(front>rear) printf("Queue Underflow !!!!"); else for(i=front;i<=rear;i++) { printf("\n %d",queue[i]); } getch(); break; case 4: exit(0); break; } } }
OUTPUT
1. INSERT
2. DELETE
3. DISPLAY
4. EXIT
Enter Your Choice : 1
ENTER Element : 50
1. INSERT
2. DELETE
3. DISPLAY
4. EXIT
Enter Your Choice : 1
ENTER Element : 100
1. INSERT
2. DELETE
3. DISPLAY
4. EXIT
Enter Your Choice : 1
ENTER Element : 150
1. INSERT
2. DELETE
3. DISPLAY
4. EXIT
Enter Your Choice : 1
ENTER Element : 200
1. INSERT
2. DELETE
3. DISPLAY
4. EXIT
Enter Your Choice : 1
ENTER Element : 250
1. INSERT
2. DELETE
3. DISPLAY
4. EXIT
Enter Your Choice : 1
QUEUE OVERFLOW!!!!!!!!!!!!!!!
1. INSERT
2. DELETE
3. DISPLAY
4. EXIT
Enter Your Choice : 3
Queue Elements :
50
100
150
200
250
1. INSERT
2. DELETE
3. DISPLAY
4. EXIT
Enter Your Choice : 2
50 is deletion element
1. INSERT
2. DELETE
3. DISPLAY
4. EXIT
Enter Your Choice : 2
100 is deletion element
1. INSERT
2. DELETE
3. DISPLAY
4. EXIT
Enter Your Choice : 2
150 is deletion element
1. INSERT
2. DELETE
3. DISPLAY
4. EXIT
Enter Your Choice : 2
200 is deletion element
1. INSERT
2. DELETE
3. DISPLAY
4. EXIT
Enter Your Choice : 2
250 is deletion element
1. INSERT
2. DELETE
3. DISPLAY
4. EXIT
Enter Your Choice : 2
QUEUE UNDERFLOW
share with your bca friends
- install our bcanotesnepal application from the play store: BCA Notes NepalDo does not forget to like our Facebook page: www.facebook.com/bcanotesnepal
Facebook Groups https://www.facebook.com/groups/bcanotesnepal
Join In our Facebook Group https://www.facebook.com/groups/1200219363518714/
if you need a Downloadable link once message us on-page you can get at a time.
This post is posted for not further third-party purposes.
Copyright By:- Bcanotesneapl
Not allowed to upload these notes to other sites.
Like our Facebook Page https://www.facebook.com/bcanotesnepal/
if you want to download this PDF comment on us we will provide you a downloadable link.
if you like please share this post with your friend who studies in BCA
if you have any query please comment below,
if you like our sites. you can visit again for the latest updates notes of different BCA subjects of Presentation and different topics with assignment questions and solutions.
Don’t forget to like our page and post also share with your friend and having your group.
if you have any questions you can drop or share them with me using the comment box I will try to answer your question.
Like our Facebook Page https://www.facebook.com/bcanotesnepal/