0% found this document useful (0 votes)
16 views2 pages

QUEUE1

This document contains a C program that implements a menu-driven queue operation using an array. It allows users to insert elements at the rear, delete elements from the front, and display the contents of the queue. The program handles overflow and underflow conditions and continues to run until the user chooses to exit.

Uploaded by

prafulla_mng
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

QUEUE1

This document contains a C program that implements a menu-driven queue operation using an array. It allows users to insert elements at the rear, delete elements from the front, and display the contents of the queue. The program handles overflow and underflow conditions and continues to run until the user chooses to exit.

Uploaded by

prafulla_mng
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

// menu driven program to perform queue operation

#include<stdio.h>
int R=0,F=0,N,Q[10],choice,element,y;
void display();
int delete_front();
void insert_rear() ;
#define N 5

void insert_rear()
{
if(R>N)
{ printf("\nqueue is overflow\n");
return;}
else
R=R+1;
printf("\nenetr the element to insert\n");
scanf("%d",&element);
Q[R]=element;
printf("\nelement is inserted\n");
if(F==0)
F=1;
}
int delete_front()
{
if(F==0)
{
printf("\nUnderflow\n");
exit(0);
}
else
y=Q[F];
if(F==R)
F=0,R=0;
else
F=F+1;
return y;
}

void display()
{
int i;
if(F==0)
{
printf("\nQueue is empty\n");
getch();
return;
}
printf("\n Queue elements are:\n");
for (i=F;i<=R;i++)
printf("%d\t",Q[i]);
}

void main()
{
clrscr();
while(1)
{ int d;
printf("\n1--insert element to Q\n");
printf("2--delete element from Q\n");
printf("3--display the contenets of Q\n");
printf("Enter the option");
scanf("%d",&choice);
if(choice==1)
insert_rear();
else if (choice==2)
{
d=delete_front();
printf("deleted element is %d",d);
}
else if(choice==3)
display();
else
exit(0);

}
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy