How to fix this error?
Code:
#include <stdio.h>
#include <stdlib.h>
struct queue{
int size;
int f;
int r;
int * arr;
};
int isEmpty(struct queue *q){
if(q->r==q->f){
return 1;
}
return 0;
}
int isFull(struct queue *q){
if(q->r==q->size-1){
return 1;
}
return 0;
}
void enqueue(struct queue *q, int val){
if(isFull(q)){
printf(“This Queue is full\n”);
}
else{
q->r++;
q->arr[q->r]=val;
}
}
int dequeue(struct queue *q){
int a = -1;
if(isEmpty(q)){
printf(“This Queue is Empty\n”);
}
else{
q->f++;
a = q->arr[q->f];
}
return a;
}
void display(struct queue *q){
while(q->r != q->f){
printf(“%d\n”,q->arr[q->r]);
q->r++;
return 0;
}
int main()
{
int O, val;
struct queue q;
q.size = 100;
q.f = q.r = -1;
q.arr = (int*)malloc(q.size*sizeof(int));
printf(“1: For Enqueue\n”);
printf(“2: For Dequeue\n”);
printf(“3: To check empty\n”);
printf(“4: To check full\n”);
printf(“5: Display Elements\n”);
printf(“6: To exit\n”);
while(q.r != q.size-1){
printf(“Enter the operation you want to perform\n”);
scanf(“%d”, &O);
switch(O)
{
case 1:
printf(“Enter the element you want to store\n”);
scanf(“%d”,&val);
enqueue(&q, val);
break;
//enqueue(&q, 14);
//enqueue(&q, 1);
case 2:
printf(“Dequeueing element %d\n”, dequeue(&q));
break;
case 3:
if(isEmpty(&q)){
printf(“Queue is Empty\n”);
}
else
printf(“Not Empty\n”);
break;
case 4:
if(isFull(&q)){
printf(“Queue is Full\n”);
}
else
printf(“Not full\n”);
break;
case 5:
printf(“Elements\n:”);
display(&q);
default:
exit(0);
}
}
return 0;
}