c-record - 10) queue

 #include<stdio.h>

#include<conio.h>

#define SIZE 3

void enqueue();

void dequeue();

void display();

int queue[SIZE],front=-1,rear=-1,ele;

void main()

{

int ch;

clrscr();

printf("\nMenu\n1.enqueue\n2.dequeue\n3.Display\n4.Exit\n");

while(1)

{

printf("\nEnter your choose Operator : ");

scanf("%d",&ch);

switch(ch)

{

case 1 :enqueue();

break;

case 2 :dequeue();

break;

case 3 :display();

break;

default:exit();

}

}

getch();

}

void enqueue()

{

if(rear==SIZE-1)

printf("\nQueue is full");

else

{

rear++;

printf("\nEnter the element to be inserted into the Queue : ");

scanf("%d",&ele);

queue[rear]=ele;

if(front==-1)

front=0;

}

}

void dequeue()

{

if(front==-1)

printf("\nQueue is empty");

else

if(front==rear)

{

printf("\nDeleted element : %d ",queue[front]);

front=-1;

rear=-1;

}

else

{

ele=queue[front];

printf("\nThe deleted element from the Queue : %d ",ele);

front++;

}

}

void display()

{

int i;

if(front==-1)

printf("\nQueue is empty");

else

{

printf("\nThe element of the Queue :\n");

for(i=front;i<=rear;i++)

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

}

}


note:- display the two image outputs continue write single output

1) output:-

alt  +f9   ------   run and

ctrl+f9   ------  compile














Comments

Popular posts from this blog

digital marketing ppt-u1

SOFTWARE

cn lab

Computer Operations and Performing - D L Unit-1-1

DS-Record-mca-04) write a program for evaluating a given postfix expression using stack.

DBMS Degree Lab Records

Unit 2: Foundations of Ownership, Security Related Concepts in Blockchain

Unit-1 Foundations of Software Systems and Blockchain

Access the Internet to Browse Infromation & E-Mail Operation- D L Unit-2-1

6)what are the various service of internet and protocols ICT-unit-1