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

Write A Program To Implement Queue Operations

This program implements queue operations using an array-based queue data structure. It defines functions to add elements to the queue, delete elements from the queue, and display the contents of the queue. The main function initializes the queue, then presents a menu for the user to add, delete, display, or exit. It calls the appropriate queue function based on the user's selection and loops until they choose to exit.
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views

Write A Program To Implement Queue Operations

This program implements queue operations using an array-based queue data structure. It defines functions to add elements to the queue, delete elements from the queue, and display the contents of the queue. The main function initializes the queue, then presents a menu for the user to add, delete, display, or exit. It calls the appropriate queue function based on the user's selection and loops until they choose to exit.
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

Write A Program To Implement Queue Operations

#include <stdio.h> #include <conio.h> #include <stdlib.h> #define MAX 10 struct queue { int *data[MAX]; int front rear; !; "oid add#struct queue *q int n$ { if # q%>rear && MAX % 1 $ { 'rintf # ()n*ueue is full.( $ ; return ; ! q%>rear++ ; q%>data[q%>rear] & n ; if #q%>front && %1 $ q%>front & 0 ; ! int del#struct queue *q$ { int , ; if # q%>front && %1 $ { 'rintf # ()n*ueue is -.'t/.( $; return 0122 ; ! , & q%>data[q%>front] ; if # q%>front && q%>rear $ q%>front & q%>rear & %1 ; else q%>front ++ ; ! "oid dis'#struct queue q$ { int i; if#q.front&&%1$ { return , ; 'rintf#(*ueue 3s -.'t/.($; return ; ! for#i&q.front;i<&q.rear;i++$ { 'rintf#(4d)t( q.data[i]$; !

! "oid .ain# $ { struct queue q; int n ch ,; q.front & %1; q.rear & %1; clrscr# $ ; 5hile#1$

{ 'rintf#()n1.Add)n6.7elete)n8. 7is'la/($; 'rintf#()n9.-,it)n-nter :our ;hoice< ($; scanf#(4d( =ch$; s5itch#ch$ { case 1< 'rintf#(-nter A 0u.ber< ($; scanf#(4d( =n$; add#=q n$; brea>; case 6< ,&del#=q$; 'rintf#(4d -le.ent 7eleted( ,$; brea>; case 8< dis'#q$; brea>; case 9< e,it#0$; default< 'rintf#(3n"alid ;hoice< ($; ! ?* @5itch -nd *? ! ?* Ahile -nd *? ! ?* Main -nd *?

Designed By S.Praveen Reddy, Soft are Developer

You might also like