Join Our Email Alerts-Subscribe
Important Note:Login & Check Your Email Inbox and Activate Confirmation Link



Enter Your Email :

Copyright Disclaimer:
Section 107 of the Copyright Act Fair Use Contents .
We are forwarding content link(s) from our website to content website & We are not serving any contents.
Main Source:Google.com.All the Content PDF link(s) is/are obtained from GoogleSearch
for the purpose of Education & Teaching Intention. Not for commercial purpose.
Technicalsymposium.com is not liable/responsible for any copyright issues.

C++ Programming Source Codes & Study Notes-Free Download


Free Download of All Study Materials & ebooks PDF-Click & Download



C++ Program for to implement circular queue operation using template function.

#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
template<class Type>
class Queue
{
Type s[10];
int rear,front,n;
public:
Queue()
{
cout<<"\n\tEnter the Queue Size : ";
cin>>n;
rear=front=n-1;
}
void insert(Type elt)
{
if((rear+1)%n!=front)
{
rear=(rear+1)%n;
s[rear]=elt;
}
else
cout<<"\n\tQueue is full.Can't insert "<<elt<<endl;
}
void remove()
{
if(front==rear)
cout<<"\n\tQueue is empty.\n";
else
{
front=(front+1)%n;
cout<<"\n\tRemoved elt : "<<s[front];
}
}
void que_operation();
void display();
};
template<class Type>
void Queue<Type> :: display()
{
if(rear!=front)
{
cout<<"\n\t\tQueue Content :\n\n\t";
for(int i=(front+1)%n;;i=(i+1)%n)
{
cout<<s[i]<<"\t";
if(i==rear) break;
}
}
else
cout<<"\n\tEmpty Queue Can't Be Print\n";
}
template<class Type>
void Queue<Type> :: que_operation()
{
int choice=1,i;
Type elt;
while(choice>0 && choice<3)
{
cout<<"\n\n\t1.Insert\t2.Remove\tAny Key To Exit\n\tChoice : ";
cin>>choice;
switch(choice)
{
case 1 : //insert
cout<<"\n\tEnter the Elt to insert : ";
cin>>elt;
insert(elt);
display();
break;
case 2 : //remove
remove();
display();
break;
}
}
}
void main()
{
clrscr();
cout<<"\n\t\tQUEUE OPERATION USING TEMPLATE\n\n";
cout<<"\n\t INT\n";
Queue<int> que1;
cout<<"\n\t FLOAT\n";
Queue<float> que2;
int ch;
while(1)
{
cout<<"\n\t\t\tQUEUE OPERATION \n\n";
cout<<"\t1.INT QUEUE\t2.FLOAT QUEUE\tAny Key To Exit\n\tChoice : ";
cin>>ch;
switch(ch)
{
case 1 : //perform queue operation on int queue
que1.que_operation();
break;
case 2 : //float
que2.que_operation();
break;
default : exit(0);
}
}
}

 


Technicalsymposium.com-Free Study Materials PDF-Download




Technicalsymposium.com-Download All Study Notes PDF




Technicalsymposium.com-Free Live Support-Chat with Our Experts

Official Contact: +91-9245556793 (Whatsapp Message / SMS / Voice Call)


Our Expert team is ready to answer all your questions immediately-Feel free to speak in Tamil/English.

(Example:Events info/Lecture Notes/Off-Campus & All Jobs/Projects & All education information)

Working hrs (IST): (Morning: 10:00AM-3:00 PM) and (Evening:5:00 PM to 10:00 PM)

All Latest Question & Answer Page (FAQ)-Click here