#include<stdio.h>
#include<conio.h>
#define max 5
int queue[max],front=-1,rear=-1,item;
void enqueue(int x)
{
if(rear==max-1)
{
printf("\n\tQueue
Is Overflow");
}
else
{
if(front==-1)
{
front=0;
rear=0;
}
else
{
rear++;
}
queue[rear]=x;
}
}
void dequeue()
{
if(front==-1)
{
printf("\n\tQueue
Is Underflow");
return;
}
item=queue[front];
printf("\n\tThe
DELETED Element : %d",item);
if(front==rear)
{
front=rear=-1;
}
else
{
front++;
}
}
void display()
{
int
i;
for(i=front;i<=rear;i++)
{
printf("\t%d",queue[i]);
}
}
void main()
{
int
ch;
while(1)
{
clrscr();
printf("\n\t--------------------------");
printf("\n\t-:\tSimple
Queue\t:-");
printf("\n\t--------------------------");
printf("\n\t\t1
: Enqueue");
printf("\n\t\t2
: Dequeue");
printf("\n\t\t3
: Display");
printf("\n\t\t4
: Exit");
printf("\n\t--------------------------");
printf("\n\n\tEnter
The Choice : ");
scanf("%d",&ch);
switch(ch)
{
case
1:
printf("\n\tEnter
The Element : ");
scanf("%d",&item);
enqueue(item);
getch();
break;
case
2:
dequeue();
getch();
break;
case
3:
printf("\n");
display();
getch();
break;
case
4:
exit(0);
break;
default:
printf("\n\tIncorrect
choice");
getch();
break;
}
}
}
OUTPUT :
--------------------------
-: Simple Queue :-
--------------------------
1 : Enqueue
2 : Dequeue
3 : Display
4 : Exit
--------------------------
Enter The Choice : 1
Enter The Element : 78
Enter The Choice : 1
Enter The Element : 85
Enter The Choice : 1
Enter The Element : 96
Enter The Choice : 1
Enter The Element : 23
Enter The Choice : 1
Enter The Element : 85
Enter The Choice : 1
Enter The Element : 45
Queue Is Overflow
Enter The Choice : 3
78 85 96
23 85
Enter The Choice : 2
The DELETED Element : 78
Enter The Choice : 2
The DELETED Element : 85
Enter The Choice : 2
The DELETED Element : 96
Enter The Choice : 2
The DELETED Element : 23
Enter The Choice : 2
The DELETED Element : 85
Enter The Choice : 2
Queue Is Underflow
Enter The Choice : 4
|
Computer Science :: 11th/12th, Computer Engineering :: Degree/Diploma, Coding Concept ( C, C++ & JAVA Programming, JDBC Concept, DBMS - SQL Concept, Data Structure, Communication & Network Concept.
SIMPLE QUEUE
Subscribe to:
Posts (Atom)
Python Code Loop Program-1
#Chapter -7 Qno - 2 num=4; while(num<10): print("Number is %d"%num); num=num+1; Output Number is 4 Number is 5 Number ...
-
COMPUTER TERMINOLOGY 1) TCP/IP - Transmission Control Protocol/ Internet Protocol. 2) HTTP...
-
Programmingway@Eklavya Technosys!: PHP Exercise Solutions : PHP Exercise Solutions 1) Fill in the blanks a) The extension of a PHP cod...
-
EduTech Digital Study Contents | Ashok Sir Class - 09 IT 402 Exercises Questions Class - 10 | IIT | Introductory to IIT | ...
-
https://makecode.com/_3VxaMo6c3YPp Code 1) What is Make Code Arcade? Answer: Make Code Arcade is a Block based coding. 2) Writ...
-
Check whether the number is negative or positive after taking a number as input from the user. TextWindow . WriteLine ( "Ente...
No comments:
Post a Comment