0% found this document useful (0 votes)
44 views

Program:: Aditya Group of Educational Institutions, Surampalem

This C program implements a circular queue using functions for insertion, deletion, and display. The insertion function inserts an element into the queue if space is available, otherwise it prints an overflow message. Deletion removes an element from the front of the queue, printing the removed element. Display prints the queue elements from front to rear. The main function initializes the queue, gets a menu choice from the user, and calls the corresponding function in a loop, exiting when choice 4 is selected.

Uploaded by

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

Program:: Aditya Group of Educational Institutions, Surampalem

This C program implements a circular queue using functions for insertion, deletion, and display. The insertion function inserts an element into the queue if space is available, otherwise it prints an overflow message. Deletion removes an element from the front of the queue, printing the removed element. Display prints the queue elements from front to rear. The main function initializes the queue, gets a menu choice from the user, and calls the corresponding function in a loop, exiting when choice 4 is selected.

Uploaded by

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

DATE: PAGE NO:

PROGRAM:
#include<stdio.h>

#include<conio.h>

int front=-1,rear=-1,size;

void insertion(int cqueue[],int element)

if(front==(rear+1)%size)

printf("cqueue is overflow\n");

else

rear=(rear+1)%size;

cqueue[rear]=element;

if(front==-1)

front=front+1;

void deletion(int cqueue[])

if(front==-1)

printf("queue is underflow\n");

else if(front==rear)

printf("%d is deleted\n",cqueue[front]);

front=-1;

rear=-1;

else

ADITYA GROUP OF EDUCATIONAL INSTITUTIONS, SURAMPALEM


DATE: PAGE NO:

printf("%d is deleted\n",cqueue[front]);

front=(front+1)%size;

void display(int cqueue[])

int i;

if(front==-1)

printf("cqueue is empty");

else

i=front;

printf("cqueue elements are\n");

while(rear!=i)

printf("%d\t",cqueue[i]);

i=(i+1)%size;

printf("%d\n",cqueue[i]);

printf("front=%d\n",front);

printf("rear=%d",rear);

void main()

int cqueue[20],element;

ADITYA GROUP OF EDUCATIONAL INSTITUTIONS, SURAMPALEM


DATE: PAGE NO:

char ch;

clrscr();

printf("read size of cqueue:");

scanf("%d",&size);

do

printf("\n1.insertion 2.deletion 3.display 4.exit");

printf("\nenter ur choice:");

scanf("%d",&ch);

switch(ch)

case 1:printf("read elements:");

scanf("%d",&element);

insertion(cqueue,element);

break;

case 2:deletion(cqueue);

break;

case 3:display(cqueue);

break;

case 4:exit();

default:printf("invalid choice");

while (ch!=4);

getch();

ADITYA GROUP OF EDUCATIONAL INSTITUTIONS, SURAMPALEM


DATE: PAGE NO:

ADITYA GROUP OF EDUCATIONAL INSTITUTIONS, SURAMPALEM

You might also like