No products in the cart.

Anybody give me a program on …

CBSE, JEE, NEET, CUET

CBSE, JEE, NEET, CUET

Question Bank, Mock Tests, Exam Papers

NCERT Solutions, Sample Papers, Notes, Videos

Anybody give me a program on static queue.. Please..
  • 1 answers

Vineit Kumar Gupta 6 years, 11 months ago

#include<iostream.h> #include<conio.h> #define n 10 int queue[n]; int front=-1,rear=-1; void insertq() {if(rear==n-1) {cout<<"\n Queue is full";} else{if(rear==-1)front=rear=0; else rear++;cout<<"\n Enter the elements to be inserted in the queue: "; cin>>queue[rear];}} void delq() {if(front==-1){cout<<"\n Queue is empty";} else{cout<<"\n The element to be removed from queue: "<<queue[front]; if(front==rear) front=rear=-1; else front++;}} void print() {if(front==-1) {cout<<"\n Queue is empty";} else{cout<<"\n Queue elements: "; cout<<"\n Front"; for(int i=front;i<=rear;i++){cout<<"\t"<<queue[i];}cout<<"\t"<<rear;}} void main() {int ch;char c; do{cout<<"\n 1.Insert"<<endl; cout<<"\n 2.Delete"<<endl; cout<<"\n 3.Print"<<endl; cout<<"\n Enter your choice: "<<endl; cin>>ch; switch(ch) {case 1:insertq();break; case 2:delq();break; case 3:print();break; default:cout<<"\n Invalid choice";} cout<<"\n Do you wish to goto menu again(y/n) "; cin>>c; }while(c=='y'); getch(); }
http://mycbseguide.com/examin8/

Related Questions

What is mean by buffering in file handling?
  • 1 answers
What are called tokens
  • 2 answers

myCBSEguide App

myCBSEguide

Trusted by 1 Crore+ Students

Test Generator

Test Generator

Create papers online. It's FREE.

CUET Mock Tests

CUET Mock Tests

75,000+ questions to practice only on myCBSEguide app

Download myCBSEguide App