#include<stdio.h>
int arr[10],front=0,rear=-1,i;
void enqueue(int object){
if(rear>=10)
printf("No enough space to enqueue");
else
arr[++rear]=object;
}
void dequeue(){
if(rear==-1)
printf("No object to dequeue");
else{
printf("%d just moved out of queue",arr[front++]);
}
}
void traverse(){
if(rear==-1)
printf("No Elements to display");
else
for(i=front;i<=rear;i++)
printf("\n Queue[%d]=%d",i,arr[i]);
}
void main(){
for(i=0;i<5;i++)
enqueue(i);
traverse();
}
int arr[10],front=0,rear=-1,i;
void enqueue(int object){
if(rear>=10)
printf("No enough space to enqueue");
else
arr[++rear]=object;
}
void dequeue(){
if(rear==-1)
printf("No object to dequeue");
else{
printf("%d just moved out of queue",arr[front++]);
}
}
void traverse(){
if(rear==-1)
printf("No Elements to display");
else
for(i=front;i<=rear;i++)
printf("\n Queue[%d]=%d",i,arr[i]);
}
void main(){
for(i=0;i<5;i++)
enqueue(i);
traverse();
}
No comments:
Post a Comment