#include
#include
#include
using namespace std;
int *a=new int [5],top=-1;
void push()
{
int n,flag;
string s;
do{
system("CLS");
if((top>=-1)&&(top<5 p=""> cout<<"ENTER A DIGIT \n";
cin>>n;
a[++top]=n;
}
else
{
cout<<"STACK IS FULL \n";
flag=1;
break;
}
if(flag!=1){
cout<<"DO YOU WANT TO DO MORE OPERATION PRESS Y ELSE N \n";
cin>>s;
}
else{
cout<<"ALL SPACES ARE FULL \n";
break;
}
}
while(s=="y");
}
void pop()
{
system("CLS");
if(top==0)
{
cout<<"STACK IS EMPTHY \n";
}
else{
system("CLS");
cout<<"THE FOLLOWING NUMBER OF STACK IS"<<" "< top--;
}
}
void output()
{
system("CLS");
if(top==0)
{
cout<<"STACK IS EMPTHY \n";
}
else
{
cout<<"[";
while(top>=0)
{
if(top>=0)
cout<<" "< }
cout<<"]"< }
}
int main()
{
int x;
string s;
do{
system("COLOR F0");
system("CLS");
cout<<"FOR PUSH PRESS 1\n";
cout<<"FOR POP PRESS 2 \n";
cout<<"FOR VIEW ALL THE DIGIT PRESS 3 \n";
cout<<" FOR EXIT PRESS 4\n";
cin>>x;
switch(x)
{
case 1:{
system("CLS");
push();
break;
}
case 2:{
string s;
system("CLS");
do {
pop();
cout<<"DO YOU WANT TO DO MORE DELETION PRESS Y ELSE N \n";
cin>>s;
}
while(s=="y");
break;}
case 3:{
system("CLS");
output();
break;}
case 4:{
system("CLS");
goto i;
break;}
}
cout<<"DO YOU WANT TO DO MORE OPERATION PRESS Y ELSE N \n";
cin>>s;
}
while(s=="y");
i:
{
cout<<"PROGRAM IS CLOSE \n";}
return 0;
}
5>
#include
#include
using namespace std;
int *a=new int [5],top=-1;
void push()
{
int n,flag;
string s;
do{
system("CLS");
if((top>=-1)&&(top<5 p=""> cout<<"ENTER A DIGIT \n";
cin>>n;
a[++top]=n;
}
else
{
cout<<"STACK IS FULL \n";
flag=1;
break;
}
if(flag!=1){
cout<<"DO YOU WANT TO DO MORE OPERATION PRESS Y ELSE N \n";
cin>>s;
}
else{
cout<<"ALL SPACES ARE FULL \n";
break;
}
}
while(s=="y");
}
void pop()
{
system("CLS");
if(top==0)
{
cout<<"STACK IS EMPTHY \n";
}
else{
system("CLS");
cout<<"THE FOLLOWING NUMBER OF STACK IS"<<" "< top--;
}
}
void output()
{
system("CLS");
if(top==0)
{
cout<<"STACK IS EMPTHY \n";
}
else
{
cout<<"[";
while(top>=0)
{
if(top>=0)
cout<<" "< }
cout<<"]"<
}
int main()
{
int x;
string s;
do{
system("COLOR F0");
system("CLS");
cout<<"FOR PUSH PRESS 1\n";
cout<<"FOR POP PRESS 2 \n";
cout<<"FOR VIEW ALL THE DIGIT PRESS 3 \n";
cout<<" FOR EXIT PRESS 4\n";
cin>>x;
switch(x)
{
case 1:{
system("CLS");
push();
break;
}
case 2:{
string s;
system("CLS");
do {
pop();
cout<<"DO YOU WANT TO DO MORE DELETION PRESS Y ELSE N \n";
cin>>s;
}
while(s=="y");
break;}
case 3:{
system("CLS");
output();
break;}
case 4:{
system("CLS");
goto i;
break;}
}
cout<<"DO YOU WANT TO DO MORE OPERATION PRESS Y ELSE N \n";
cin>>s;
}
while(s=="y");
i:
{
cout<<"PROGRAM IS CLOSE \n";}
return 0;
}
No comments:
Post a Comment