Ex-9 Queue - Ll

  • October 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Ex-9 Queue - Ll as PDF for free.

More details

  • Words: 181
  • Pages: 3
Ex.No:9 LINKED LIST IMPLEMENTATION-QUEUE PROGRAM #include<stdio.h> #include #include<stdlib.h> struct queue { int data; struct queue *next; }; struct queue *head,*temp; void enqueue() { struct queue *enqueue; enqueue=(struct queue*)malloc(sizeof(struct queue)); printf("\nenter the data..."); scanf("%d",&enqueue->data); if(head==NULL) { head=enqueue; head->next=NULL; temp=enqueue; } else { temp->next=enqueue; enqueue->next=NULL; temp=enqueue; } } void dequeue() { struct queue *dequeue; int found=0; if(head==NULL) { printf("\ncreate the queue first....."); } else { head=head->next; found=1; }

if(found==1) printf("\nthe element is dequeueed..."); } void modify() { struct queue *mod,*data; int x,num,no; printf("\nenter the number to be modify...."); scanf("%d",&no); for(mod=head;mod!=NULL;mod=mod->next) { if(mod->data==no) { printf("\nenter the new number...."); scanf("%d",&num); mod->data=num; x=1; } } if(x==1) printf("\nthe number is modified..."); else printf("Element does not exist\n"); } void disp() { struct queue *disp; if(head==NULL) printf("\nthe queue is empty.."); else { for(disp=head;disp!=NULL;disp=disp->next) printf("%u\t%d\t%u\n",disp,disp->data,disp->data); } } void main() { int ch; char a='y'; clrscr(); printf("1.enqueue\t2.dequeue\t3.display\t4.modify\t5.exit\n"); do { printf("\nenter the choice......");

scanf("%d",&ch); switch(ch) { case 1: enqueue(); break; case 2: dequeue(); break; case 3: disp(); break; case 4: modify(); break; case 5: exit(0); break; default: printf("\nenter the correct choice."); } printf("do u want to continue.....(y/n):"); a=getche(); } while(a=='y'); getch(); }

Related Documents

Queue Ll Output-2
October 2019 6
Ex-9 Queue - Ll
October 2019 12
Sol Ex9
October 2019 5
Ll
July 2020 20
Ll
July 2019 38
Ll
November 2019 29