For Algorithm and Program related to queue using integer array follow this link :
https://codstudio.wordpress.com/2014/02/23/queue-using-integer-array/
Program using linked list :
/*********************************** AUTHOR- TANMAY BARANWAL C#ODE STUDIO ***********************************/ #include"iostream" #include"conio.h" using namespace std; class linkedq { struct queue { int info; queue *link; }*front,*rear; public: linkedq() { front=NULL; rear=NULL; } int push(int); int pop(); int disp(); }; int linkedq::push(int x) { queue *ptr; ptr=new queue; ptr->info=x; ptr->link=NULL; if(front==NULL) front=ptr; else rear->link=ptr; rear=ptr; disp(); } int linkedq::pop() { queue *ptr; if(front==NULL) cout<<"\nUNDERFLOW "; else { ptr=front; front=front->link; } cout<<"\nELEMENT DELETED IS : "<<ptr->info; disp(); } int linkedq::disp() { queue *ptr; if(front==NULL) { cout<<"\nUNDERFLOW "; } else { ptr=front; cout<<"\nQUEUE => "; while(ptr!=NULL) { cout<<ptr->info<<"=> "; ptr=ptr->link; } cout<<" NULL"<<endl; } } main() { linkedq q; int num,choice; do { cout<<"\n1:PUSH" <<"\t2:POP" <<"\t3:DISPLAY" <<"\t4:EXIT"<<endl; cout<<"\nMAKE CHOICE : "; cin>>choice; switch(choice) { case 1: cout<<"\nINSERT VALUE : "; cin>>num; q.push(num); break; case 2: q.pop(); break; case 3: q.disp(); break; case 4: cout<<"\nEXITING PROGRAM "<<endl; break; default: cout<<"\nENTER CORRECT CHOICE"; } cout<<"________________________________________"<<endl; }while(choice!=4); cout<<"\n\n\tPROGRAMMING @ C#ODE STUDIO"; getch(); }
OUTPUT – :