Professional Documents
Culture Documents
}
char* Front() {
void enqueue(char str[]) {
return front->data;
Node* temp = (Node*)
malloc(sizeof(Node)); }
strcpy(temp->data, str);
rear = temp;
}
int main() Discussion: This program demonstrates the
{ implementation of a queue data structure using
print(); Linked List in C. At first the code defines a “Node”
structure which contains a character array data and a
enqueue("Tikka");
pointer to the next node. Two global pointers ‘front’
print(); and ‘rear’ are used to track the front and rear
enqueue("Channu"); elements of the queue. There used six user define
functions-to check the queue is empty or
print();
full(isEmpty() and isFull()), enqueue and dequeue
enqueue("Afsar"); operation(enqueue() and dequeue()),tracking the
print(); front(*Front()) and printing the results(void print()).
In the main() function, the code showcase these
enqueue("Nozrul");
queue operation by enqueuing and dequeuing
print(); elements and printing the queue’s state at the
dequeue(); different points.
print();
dequeue();
print();
dequeue();
print();
dequeue();
print();
return 0;
OUTPUT: