Skip to main content

Posts

Showing posts from August 11, 2017

LINKED QUEUE IN PUSH, POP & PEEK OPERATIONS

CODING: #include<stdio.h> #include<conio.h> struct node {  int data;  struct node *next; }; struct queue {  struct node *front;  struct node *rear; }; struct queue *q; void create_queue(struct queue *); struct queue *insert(struct queue *); struct queue *delete_element(struct queue *); struct queue *display(struct queue *); int peek(struct queue *); void main() { int ch,num; clrscr(); create_queue(q); do  {   printf("\nS E L E C T  C H O I C E");   printf("\n1.INSERT");   printf("\n2.DELETE");   printf("\n3.PEEK");   printf("\n4.DISPLAY");   printf("\n5.EXIT");   printf("\nEnter the Number:");   scanf("%d",&ch);   switch(ch)    {    case 1:    q=insert(q);    break;    case 2:    q=delete_element(q);    break;    case 3:    num=peek(q);    printf("%d is stored at the top of Queue.",num);    break;    case 4:    q=display(q);    break