123 Eng

Engineering the engineers™


Latest Jobs   Forum Map

 


Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

   Computer Science / IT
   Electronics
   Electrical
   Mechanical
   Chemical
   Civil

   CAT / MBA

   GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Sitemap
Terms of use

Displaying  Source Code(s)  
 

 
stack and queue implementation using arrays

--------------------------------------------------------------------------------



#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
int pushs();
int pops();
int pushq();
int popq();

int stack[10];
int q[10];

int main()
{
char m;
loop3:
clrscr();
cout<<"Select any one
<BR>;
cout<<"e->Exit from the program<BR>;
cout<<"s->Stack<BR>;
cout<<"q->Queue<BR>;
loop1:
cin>>m;

if(m=='S' || m=='Q')
{
cout<<"Use small letters<BR>;
goto loop1;
}

switch(m)
{

case 's':
char st;
clrscr();
cout<<"
Stack<BR>;
cout<<"-----";
do
{
cout<<"
Select any one of the operation
<BR>;
cout<<"u->push a value to the stack<BR>;
cout<<"o->pop a value from the stack<BR>;
cout<<"b->Back
<BR>;
loop2:
cin>>st;
if(st=='E' || st=='U'|| st=='O'|| st=='B')
{
cout<<"Use small letters<BR>;
goto loop2;
}

if(st=='b')
goto loop3;

switch(st)
{
case 'u':
int phs=pushs();
if(phs==1)
cout<<"The value is pushed into the stack<BR>;
else
cout<<"The stack is full<BR>;
break;
case 'o':
int pps=pops();
if(pps==0)
cout<<"The Stack is empty<BR>;
else
cout<<"The top of the stack is: "<<pps<<endl;
break;
default:
cout<<"Selection should be valid";
break;
}
} while(st!='e');
break;
case 'q':

char qt;
clrscr();
cout<<"
Queue<BR>;
cout<<"-----";
do
{
cout<<"
Select any one of the operation
<BR>;
cout<<"u->push a value to the queue<BR>;
cout<<"o->pop a value from the queue<BR>;
cout<<"b->Back
<BR>;

loop4:
cin>>qt;
if(qt=='E' || qt=='U'|| qt=='O'|| qt=='B')
{
cout<<"Use small letters<BR>;
goto loop4;
}

if(qt=='b')
goto loop3;

switch(qt)
{

case 'u':
int phq=pushq();
if(phq==1)
cout<<"The value is pushed in the queue.<BR>;
else
cout<<"The queue is full<BR>;
break;
case 'o':
int ppq=popq();
if(ppq==0)
cout<<"The queue is empty<BR>;
else
cout<<"The value poped from the queue is: "<<ppq<<endl;
break;
default:
cout<<"Selection should be valid";
break;

}
} while(qt!='e');
break;
case 'e':
exit (0);
default:
cout<<"Selection should be valid";
break;

}
getch();
return 0;
}

int pushs()
{
int vs,j=0;
cout<<"Enter the value that you want to push<BR>;
cin>>vs;
while(stack[j]=='
 

 

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved © copyright 123ENG