Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
0 of .
Results for:
No results containing your search query
P. 1
Lab 8

Lab 8

Ratings: (0)|Views: 6 |Likes:
Published by Sandeep V Gowda

More info:

Published by: Sandeep V Gowda on Nov 12, 2010
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as RTF, PDF, TXT or read online from Scribd
See more
See less





8.Write a C Program to simulate the working of a circular queueof integers using an array. Provide the following operations:a.Insertb.Deletec.Display.PROGRAM
#include<stdio.h>#include<conio.h>#include<process.h>#define size 5int cqueue[size];int front=0,rear=-1,count;void cinsert(int);int cdelete1();void cdisplay();void main(){int ele;int choice;clrscr();while(1){printf("enter choice 1.Insert 2.Delete 3.Display 4.Exit\n");scanf("%d",&choice);switch(choice){case 1:printf("Enter the element\n");scanf("%d",&ele);cinsert(ele);break;case 2:ele=cdelete();if(ele==-999){printf("Queue empty\n");}else{printf("The element deleted is %d\n",ele);}break;case 3:cdisplay();break;case 4:exit(0);default:printf("Invalid choice\n");break;}}}void cinsert(int ele){if(count==size){printf("Queue full\n");}
else{count=count+1;rear=(rear+1)%size;cqueue[rear]=ele;}}int cdelete(){int temp;if(count==0){temp=-999;}else{count=count-1;temp=cqueue[front];front=(front+1)%size;}return(temp);}void cdisplay(){int i,j;j=front;for(i=0;i<count;i++){printf("%d\t\n",cqueue[j]);j=(j+1)%size;}}
enter choice 1.Insert 2.Delete 3.Display 4.Exit1Enter the element10enter choice 1.Insert 2.Delete 3.Display 4.Exit1Enter the element20enter choice 1.Insert 2.Delete 3.Display 4.Exit31020enter choice 1.Insert 2.Delete 3.Display 4.Exit2The element deleted is 10enter choice 1.Insert 2.Delete 3.Display 4.Exit

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->