#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
";
cout<<"e->Exit from the program
";
cout<<"s->Stack
";
cout<<"q->Queue
";
loop1:
cin>>m;
if(m=='S' || m=='Q')
{
cout<<"Use small letters
";
goto loop1;
}
switch(m)
{
case 's':
char st;
clrscr();
cout<<"
Stack
";
cout<<"-----";
do
{
cout<<"
Select any one of the operation
";
cout<<"u->push a value to the stack
";
cout<<"o->pop a value from the stack
";
cout<<"b->Back
";
loop2:
cin>>st;
if(st=='E' || st=='U'|| st=='O'|| st=='B')
{
cout<<"Use small letters
";
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
";
else
cout<<"The stack is full
";
break;
case 'o':
int pps=pops();
if(pps==0)
cout<<"The Stack is empty
";
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
";
cout<<"-----";
do
{
cout<<"
Select any one of the operation
";
cout<<"u->push a value to the queue
";
cout<<"o->pop a value from the queue
";
cout<<"b->Back
";
loop4:
cin>>qt;
if(qt=='E' || qt=='U'|| qt=='O'|| qt=='B')
{
cout<<"Use small letters
";
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.
";
else
cout<<"The queue is full
";
break;
case 'o':
int ppq=popq();
if(ppq==0)
cout<<"The queue is empty
";
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
";
cin>>vs;
while(stack[j]=='
#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
";
cout<<"e->Exit from the program
";
cout<<"s->Stack
";
cout<<"q->Queue
";
loop1:
cin>>m;
if(m=='S' || m=='Q')
{
cout<<"Use small letters
";
goto loop1;
}
switch(m)
{
case 's':
char st;
clrscr();
cout<<"
Stack
";
cout<<"-----";
do
{
cout<<"
Select any one of the operation
";
cout<<"u->push a value to the stack
";
cout<<"o->pop a value from the stack
";
cout<<"b->Back
";
loop2:
cin>>st;
if(st=='E' || st=='U'|| st=='O'|| st=='B')
{
cout<<"Use small letters
";
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
";
else
cout<<"The stack is full
";
break;
case 'o':
int pps=pops();
if(pps==0)
cout<<"The Stack is empty
";
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
";
cout<<"-----";
do
{
cout<<"
Select any one of the operation
";
cout<<"u->push a value to the queue
";
cout<<"o->pop a value from the queue
";
cout<<"b->Back
";
loop4:
cin>>qt;
if(qt=='E' || qt=='U'|| qt=='O'|| qt=='B')
{
cout<<"Use small letters
";
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.
";
else
cout<<"The queue is full
";
break;
case 'o':
int ppq=popq();
if(ppq==0)
cout<<"The queue is empty
";
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
";
cin>>vs;
while(stack[j]=='
No comments:
Post a Comment