display simple queue list

im having problem with the output
==============
front->12->1>-1813->1813 ->12
==============
where the things at the back shout not be display as the user only entered 1 value which is 12
and it also seems cannot delete number using the dequeue function



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include <stdio.h>
#include <stdlib.h>

typedef struct QUEUE
{	int head, tail;
	int list[4];
}queue;

void create(queue *q);
int full(queue *q);
int empty (queue *q);
void enqueue(queue *q);
void dequeue(queue *q);
void display(queue *q);


void main()   ///main function
{	int choice;
	queue q;
	create (&q);

	display (&q);
	printf("\nEnter choice: \n1-Enqueue \n2-Dequeue \n3-Exit\n");
	scanf("%d", &choice);

	while(choice!=3)
	{	switch (choice)
		{	case 1: enqueue(&q);
					break;
			case 2: dequeue(&q);
					break;
			default:
				printf("\nchoose again");
				break;
			}
			display (&q);
			printf("\nEnter choice");
			scanf("%d", &choice);

	}
	printf("\nEnd of run\n");
}





void create (queue *q)
{	q->head=0;
	q->tail=0;
}

int empty (queue *q)
{	if(q->tail==0)
		return (1);
	else
		return (0);
}

int full (queue *q)
{	if (q->tail==4)
		return (1);
	else
		return (0);
}

void enqueue (queue *q)
{	int data;

	if (full(q)==1)
		printf("\nQueue is full");
	else
	{	printf("\nEnqueue Integer: ");
		scanf("%d",&data);
		q->list[q->tail]=data;
		q->tail++;
	}
}

void dequeue (queue *q)
{	if (empty(q)==1)
		printf("\nQueue is Empty");
	else
		{	q->head++;
		}
}

void display (queue *q)
{	int i;

	if (empty(q)==1)
		printf("\nQueue Empty");
	else
		{	printf("\nFront->");
			for(i=0; i<=3; i++)
				printf("%d->",q->list[i]);
		}
}  
You are not making use of your queue's internals to display the list. You are simply iterating over everything in the QUEUE::list array. What about QUEUE::head and QUEUE::tail?
Topic archived. No new replies allowed.