C Program to Implement the multiple priority queue.

Data structures using C,Priority QUEUE is a abstract data type in which the objects are inserted with respect to certain priority. In this program, we created the simple multiple priority queue. Read more about C Programming Language .

* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
* Happy Coding

#define MAX 3
struct myqueue {
int f, r;
int a[MAX];
typedef struct myqueue pqueue;
void insert(pqueue *);
void delete(pqueue *);
void display(pqueue *, pqueue *, pqueue *);
int isempty(pqueue *);
int isfull(pqueue *);

main() {
pqueue q[3];
int ch, i, n;
for (i = 0; i < 3; i++) {
q[i].f = 0;
q[i].r = -1;
while (1) {
printf("n******* MENU ********n");
printf("nEnter your choice:n");
scanf("%d", &ch);
switch (ch) {
case 1:
printf("nEnter priority:n");
scanf("%d", &n);
insert(&q[n - 1]);

case 2:
if (isempty(&q[0])) {
if (isempty(&q[1])) {
if (isempty(&q[2])) {
printf("nAll queues are empty..n");
} else
n = 2;
} else
n = 1;
} else
n = 0;

case 3:
display(&q[0], &q[1], &q[2]);
case 4:
printf("nInvalid choice..");

int isempty(pqueue *q) {
if (q->f > q->r)
return 1;
return 0;

int isfull(pqueue *q) {
if (q->r == MAX - 1)
return 1;
return 0;

void insert(pqueue *q) {
int x;
if (isfull(q)) {
printf("nQueue overflow..");
} else {
printf("nEnter the element to be inserted:n");
scanf("%d", &x);
q->a[q->r] = x;

void delete(pqueue *q) {
int n;
n = q->a[q->f];
printf("The deleted element is = %d", n);

void display(pqueue *q1, pqueue *q2, pqueue *q3) {
int i;
if (isempty(q1))
printf("nQueue1 is empty..");
printf("nThe contents of queue1 are:n");
for (i = q1->f; i <= (q1->r); i++) {
printf("%dt", q1->a[i]);
if (isempty(q2))
printf("nQueue2 is empty..");
printf("nThe contents of queue2 are:n");
for (i = q2->f; i <= (q2->r); i++) {
printf("%dt", q2->a[i]);
if (isempty(q3))
printf("nQueue3 is empty..");
printf("nThe contents of queue3 are:n");
for (i = q3->f; i <= (q3->r); i++) {
printf("%dt", q3->a[i]);

Read more Similar C Programs
Data Structures

Learn C Programming

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

Leave a Reply