Jan

23

#include<stdio.h>
#include<conio.h>
#define maxsize 5
int Q[maxsize];
void main(){
int front=-1,rear=-1;
int item,i;
char ch=’y’;
do{
printf("Enter Item into Q: ");
scanf("%d",&item);
if(rear>=maxsize-1){
printf("\n Queue oveflow");
}
else{
rear=rear+1;
Q[rear]=item;
}
if(front==-1){
front=0;
}
printf("Do u want to continue: ");
fflush(stdin);
scanf("%c",&ch);
}while(ch==’y’||ch==’Y’);
printf("Do u want to delete item from Q: ");
fflush(stdin);
scanf("%c",&ch);
while(ch==’y’){
if(front<0){
printf("Q is Empty ");
}
else{
item=Q[front];
printf("Deleteed item is: %d\n",item);
front=front+1;
}
if(front>rear){
front=rear=-1;
}
printf("Do u want to delete item from Q: ");
fflush(stdin);
scanf("%c",&ch);
}
/*printf("————–DISPLAY VALUES FROM Q——–");
for(i=front;i<=rear;i++){
printf("%d\n",Q[i]);

}*/
}


Leave a Reply