Queue L question and input output specification are in the p
Queue L
question and input output specification are in the picture
in great need for answer in c programing language
which can output as the sample output when there is sample input as the picture shows, according to the question
T T
and so many time someone give me the ans that need more info but didnt tell me what info he need.. it makes me really down
..sorry i really dont have other infoT_T
thx for ur kindly help_
Solution
Try this program,
#include<conio.h>
#include<stdio.h>
#define max 5
int queue[max],front=0,rear=0;
int menu();
void enqueue();
void dequeue();
void display();
void main()
{
int ch;
clrscr();
printf(\"\ ProgrammingUnit.com - Free Source Codes\ \");
printf(\"\ Queues using Arrays\ \");
do
{
ch=menu();
switch(ch)
{
case 1: enqueue();
break;
case 2: dequeue();
break;
case 3: display();
break;
case 4: exit();
break;
default:printf(\"\ Please enter a valid choice!!\");
}
}while(1);
}
int menu()
{
int ch;
printf(\"\ 1.ENQUEUE \ 2.DEQUEUE \ 3.DISPLAY \ 4.EXIT\");
printf(\"\ Enter your Choice:\");
scanf(\"%d\",&ch);
return ch;
}
void enqueue()
{
int element;
if(rear==max)
{
printf(\"\ Overflow!!\");
}
else
{
printf(\"\ Enter Element:\");
scanf(\"%d\",&element);
queue[rear++]=element;
printf(\"\ %d Enqueued at %d\",element,rear);
}
}
void dequeue()
{
if(rear==front)
{
printf(\"\ Underflow!!\");
}
else
{
front++;
printf(\"\ Element is Dequeued from %d\",front);
}
}
void display()
{
int i;
if(front==rear)
{
printf(\"\ Queue is Empty!!!\");
}
else
{
printf(\" \ \");
for(i=front;i<max;i++)
{
printf(\" | %d \",queue[i]);
}
printf(\"|\");
}
}
Thank you!


