//Write a prgram to insert & delete the elemnts from queue
#include
#include
#include
class queue
{
private:
int i,r,q[25],front,rear;
public:
void enqueue(int);
void dequeue();
void getdata();
};
void queue::getdata()
{
clrscr();
cout<cin>>r;
cout<for(i=0;i {
cin>>q[i];
}
front=q[0];
rear=q[2];
}
void queue::dequeue()
{
int item;
if(front==0)
{
cout<exit(0);
}
else
{
item=q[1];
}
if(front==rear)
{
front=0;
rear=0;
}
else
{
front=front+1;
}
cout<for(i=0;i {
cout<<"\t"< }
}
void queue::enqueue(int item)
{
if(rear==r)
{
cout<exit(0);
}
else
{
if(rear==0 &&front==0)
{
front=1;
rear=1;
}
r=r+1;
q[r]=item;
}
cout<for(i=0;i {
cout<<"\t"< }
}
void main()
{
int ch,no;
clrscr();
char cho;
queue q;
q.getdata();
cout<cout<<"want to perform on queue:";
cout<cout< cin>>ch;
do
{
switch(ch)
{
case 1:
cout<cin>>no;
q.enqueue(no);
break;
case 2:
q.dequeue();
break;
}
cout<cin>>cho;
}
while(cho=='y'||cho=='Y');
}
program to insert & delete the elemnts from queue.
Labels:
C++,
C++ Assignment
Subscribe to:
Post Comments (Atom)
If you face any Problem in viewing code such as Incomplete "For Loops" or "Incorrect greater than or smaller" than equal to signs then please collect from My Web Site CLICK HERE
More Useful Topics... |
|
History Of C..
In the beginning was Charles Babbage and his Analytical Engine, a machine
he built in 1822 that could be programmed to carry out different computations.
Move forward more than 100 years, where the U.S. government in
1942 used concepts from Babbage’s engine to create the ENIAC, the first
modern computer.
Meanwhile, over at the AT&T Bell Labs, in 1972 Dennis Ritchie was working
with two languages: B (for Bell) and BCPL (Basic Combined Programming
Language). Inspired by Pascal, Mr. Ritchie developed the C programming
language.
he built in 1822 that could be programmed to carry out different computations.
Move forward more than 100 years, where the U.S. government in
1942 used concepts from Babbage’s engine to create the ENIAC, the first
modern computer.
Meanwhile, over at the AT&T Bell Labs, in 1972 Dennis Ritchie was working
with two languages: B (for Bell) and BCPL (Basic Combined Programming
Language). Inspired by Pascal, Mr. Ritchie developed the C programming
language.
My 1st Program...
#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n");
printf ("\t\t\t\"Life is Good...\"\n");
printf ("\t\t\t********************************");
getch ();
}
Next Step...
#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n\n\n\n\n");
printf ("\t\t\t --------------------------- \n\n");
printf ("\t\t\t | IGCT, Info Computers, INDIA | \n\n");
printf ("\t\t\t --------------------------- ");
}
No comments:
Post a Comment