#include<stdio.h>
#include<conio.h>
#define max 10
void insert(int);
int deletee();
void display();
int f=-1;
int r=-1;
int a[max];
void main()
{
int ch,value;
while(1)
{
printf("\n1.Insert Data");
printf("\n2.Delete Data");
printf("\n3.Display Data");
printf("\n4.Exit");
printf("\nEnter Choice\n");
scanf("%d",&ch);
switch(ch)
{
case 1:
if(r==9)
{
printf("\nQueue Overflow");
}
else{
printf("\nEnter Value to Insert\n");
scanf("%d",&value);
insert(value);
}
break;
case 2:
if(f==-1)
{
printf("\nQueue Underflow");
}
else{
int n=deletee();
f++;
printf("value %d deleted",n);
}
break;
case 3:
display();
break;
case 4:
exit(1);
break;
default:
printf("\Invalid Input");
break;
}
}
}
void insert(int value)
{
if(f==-1 && r==-1)
{
f++;
r++;
a[r]=value;
}
else{
r++;
a[r]=value;
}
}
int deletee()
{
return a[f];
}
void display()
{
int i;
printf("\n The list of Data are:\n");
for(i=f;i<=r;i++)
{
printf("\n%d",a[i]);
}
}
#include<conio.h>
#define max 10
void insert(int);
int deletee();
void display();
int f=-1;
int r=-1;
int a[max];
void main()
{
int ch,value;
while(1)
{
printf("\n1.Insert Data");
printf("\n2.Delete Data");
printf("\n3.Display Data");
printf("\n4.Exit");
printf("\nEnter Choice\n");
scanf("%d",&ch);
switch(ch)
{
case 1:
if(r==9)
{
printf("\nQueue Overflow");
}
else{
printf("\nEnter Value to Insert\n");
scanf("%d",&value);
insert(value);
}
break;
case 2:
if(f==-1)
{
printf("\nQueue Underflow");
}
else{
int n=deletee();
f++;
printf("value %d deleted",n);
}
break;
case 3:
display();
break;
case 4:
exit(1);
break;
default:
printf("\Invalid Input");
break;
}
}
}
void insert(int value)
{
if(f==-1 && r==-1)
{
f++;
r++;
a[r]=value;
}
else{
r++;
a[r]=value;
}
}
int deletee()
{
return a[f];
}
void display()
{
int i;
printf("\n The list of Data are:\n");
for(i=f;i<=r;i++)
{
printf("\n%d",a[i]);
}
}
No comments:
Post a Comment