#include<stdio.h>
void create(void);
void delete(void);
void display(void);
#define qmax 5
int q[qmax];
int r=-1;
int f=0;
char s[5];
int main()
{
//////////////////
while(1)
{
system("clear");
printf("\n\n\n-------------------------Single-Ended-Queue---------------------------------\n\n");
printf("\n\n 1) Enter Queue ");
printf("\n\n 2) Display");
printf("\n\n 3) Delete");
printf("\n\n 4) Exit");
printf("\n\n\n-----------------------------------------------------------------\n\n");
printf("\n\nEnter the choice :");
int x;
scanf("%d",&x);
switch(x)
{
case 1:
{
create();
break;
}
case 2:
{
display();
break;
}
case 3:
{
delete();
break;
}
case 4:
{
return;
}
default:
{printf("\n\nEnter valid Choice :\n\n");
printf("\n\n\n\n\n\nPress any Key :\n");
gets(s);
gets(s);
break;}
}
}
}
//////////////////////////////////////////////////////////////////
void create(void)
{
int data;
if(r==(qmax-1))
{
printf("\n\nQueue is over flow\n");
printf("\n\n\n\n\n\nPress any Key :\n");
gets(s);
gets(s);
return;
}
r=r+1;
printf("\n\nEnter the Queue data :");
scanf("%d",&data);
q[r]=data;
}
/////////////////////////////////////////////////////////////
void delete(void)
{
if(f>r)
{
printf("\n\nQueue is under flow");
printf("\n\n\n\n\n\n\nPress any Key :\n");
gets(s);
gets(s);
return;
}
f=f+1;
if(f>r)
{
f=0;
r=-1;
}
}
void display(void)
{
int i;
if(f==0&&r==-1)
{
printf("--->-Queue is now free---->-");
printf("\n\n\n\n\n\n\nPress any Key :\n");
gets(s);
gets(s);
return;
}
printf("\n\n\n\nrear end------>");
for(i=f;i<=r;i++)
{
printf("%d-----",q[i]);
}
printf("front end--->\n\n\n\n\n\n\nPress any Key :\n");
gets(s);
gets(s);
}
/////////////////////////////////////////////////////////////////
void create(void);
void delete(void);
void display(void);
#define qmax 5
int q[qmax];
int r=-1;
int f=0;
char s[5];
int main()
{
//////////////////
while(1)
{
system("clear");
printf("\n\n\n-------------------------Single-Ended-Queue---------------------------------\n\n");
printf("\n\n 1) Enter Queue ");
printf("\n\n 2) Display");
printf("\n\n 3) Delete");
printf("\n\n 4) Exit");
printf("\n\n\n-----------------------------------------------------------------\n\n");
printf("\n\nEnter the choice :");
int x;
scanf("%d",&x);
switch(x)
{
case 1:
{
create();
break;
}
case 2:
{
display();
break;
}
case 3:
{
delete();
break;
}
case 4:
{
return;
}
default:
{printf("\n\nEnter valid Choice :\n\n");
printf("\n\n\n\n\n\nPress any Key :\n");
gets(s);
gets(s);
break;}
}
}
}
//////////////////////////////////////////////////////////////////
void create(void)
{
int data;
if(r==(qmax-1))
{
printf("\n\nQueue is over flow\n");
printf("\n\n\n\n\n\nPress any Key :\n");
gets(s);
gets(s);
return;
}
r=r+1;
printf("\n\nEnter the Queue data :");
scanf("%d",&data);
q[r]=data;
}
/////////////////////////////////////////////////////////////
void delete(void)
{
if(f>r)
{
printf("\n\nQueue is under flow");
printf("\n\n\n\n\n\n\nPress any Key :\n");
gets(s);
gets(s);
return;
}
f=f+1;
if(f>r)
{
f=0;
r=-1;
}
}
void display(void)
{
int i;
if(f==0&&r==-1)
{
printf("--->-Queue is now free---->-");
printf("\n\n\n\n\n\n\nPress any Key :\n");
gets(s);
gets(s);
return;
}
printf("\n\n\n\nrear end------>");
for(i=f;i<=r;i++)
{
printf("%d-----",q[i]);
}
printf("front end--->\n\n\n\n\n\n\nPress any Key :\n");
gets(s);
gets(s);
}
/////////////////////////////////////////////////////////////////