Resources » Articles/Knowledge Sharing » Computer & Technology

Write a Program To Perform INSERT & DELETE Operation on the “Queue”.


Updated: Category: Computer & Technology
Author: Member Level: SilverPoints: 2


Write a Program To Perform INSERT & DELETE Operation on the “Queue”.



Write a Program To Perform INSERT & DELETE Operation on the “Queue”.

SOURCE CODE:

#include
#include
#include
int front=0,rear=0;
int i;
int QUEUE[5];
int item;
void main()
{
int opt;
int q=0;
clrscr();
printf("\nThis Program is Used to Perform INSERT & DELETE Operation on Queue");
printf("\n\n\tMain Menu.....");
printf("\n\n\t1.Insertion");
printf("\n\n\t2.Deletion");
printf("\n\n\t3.Displaying");
printf("\n\n\t4.Exit");
do
{
printf("\n\n\tEnter Your choice 1-4:");
scanf("%d",&opt);
switch(opt)
{
case 1:
printf("\n\tEnter the Element To be Inserted:");
scanf("%d",&item);
if(rear<5)
{
rear++;
QUEUE[rear]=item;
printf("\n\n\tElement Inserted");

if(front==0)
{
front=1;




rear=1;
}
}
else
{
printf("\nQueue Is Full,Insertion Not Possible");
}
break;
case 2:
if(front==0)
{
printf("\nQueue Is Empty,Deletion is Not Possible");
}
else
{
item=QUEUE[front];
printf("\n\tItem Deleted is %d ",item);
}

if(front==rear)
{
front=0;
rear=0;
}
else
front=front+1;
break;
case 3:
printf("\n\t\tQUEUE Is As:");
printf("\n\t");
for(i=front;i<=rear;i++)
{
printf("%3d",QUEUE[i]);
}

break;
case 4:
exit(1);
default:printf("\n\tWrong Choice,Enter Your Choice 1-4");

}
}while(q!=1);
getch();
}


OUTPUT

This program is used to perform INSERT AND DELETE operation on queque

Main menu.......
1. insertion
2.deletion
3.displaying
4.Exit

enter your choice 1-4:1
enter the element to be inserted:5

element inserted
enter your choice 1-4:1
enter the element to be inserted:7

Element Inserted
enter your choice 1-4:3
queue is as:
5 7
Enter your choice 1-4:2
item deleted is 5
Enter your choice 1-4:3
queque is as:
7
Enter your choice 1-4;_


Reference: Queue,data srtucture


Did you like this resource? Share it with your friends and show your love!




Responses to "Write a Program To Perform INSERT & DELETE Operation on the “Queue”."

No responses found. Be the first to respond...

Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Submit Article     Return to Article Index
    Complete the action items below to enter to win an iPad Mini from India Study Channel! in India Study Channel - Locker on LockerDome
    Awards & Gifts
    Active Members
    TodayLast 7 Daysmore...

    Online Members

    Naveed Ahmed
    More...
     
    ISC Technologies, Kochi - India. © All Rights Reserved.