#include <iostream>
using namespace std;
int stack[100], top=-1, size;
void push(int &top,int n)
{
cout << "";
}
void push()
{
if(top==size-1)
cout<<"Stack Overflow"<<endl;
else
{
top++;
cin>>stack[top];
}
}
void pop()
{
if(top==-1)
cout<<"Stack underflow"<<endl;
else
{
cout<<"deleted element is"<<stack[top]<<endl;
top--;
}
}
void print()
{
int i;
for(i=top;i>=0;i--)
cout<< " " <<stack[i]<<"";
cout<<endl;
}
int main()
{
char opt;
int o;
cin>>size;
do
{
cin>>o;
switch(o)
{
case 1:
{
push();
break;
}
case 2:
{
pop();
break;
}
}
cin>>opt;
}while(opt=='y');
print();
return 0;
}
using namespace std;
int stack[100], top=-1, size;
void push(int &top,int n)
{
cout << "";
}
void push()
{
if(top==size-1)
cout<<"Stack Overflow"<<endl;
else
{
top++;
cin>>stack[top];
}
}
void pop()
{
if(top==-1)
cout<<"Stack underflow"<<endl;
else
{
cout<<"deleted element is"<<stack[top]<<endl;
top--;
}
}
void print()
{
int i;
for(i=top;i>=0;i--)
cout<< " " <<stack[i]<<"";
cout<<endl;
}
int main()
{
char opt;
int o;
cin>>size;
do
{
cin>>o;
switch(o)
{
case 1:
{
push();
break;
}
case 2:
{
pop();
break;
}
}
cin>>opt;
}while(opt=='y');
print();
return 0;
}
#include iostream \\put angle brackets here
ReplyDeleteusing namespace std;
int stack[100], top=-1, size;
void push(int &top,int n)
{
cout << "";
}
void push()
{
if(top==size-1)
cout<<"Stack Overflow"<>stack[top];
}
}
void pop()
{
if(top==-1)
cout<<"Stack underflow"<=0;i--)
cout<< " " <>size;
do
{
cin>>o;
switch(o)
{
case 1:
{
push();
break;
}
case 2:
{
pop();
break;
}
}
cin>>opt;
}while(opt=='y');
print();
return 0;
}
absolute error
Deleteabsolute error bro
ReplyDelete#include
ReplyDeleteusing namespace std;
int stack[100], top=-1, size;
void push(int &top,int n)
{
cout << "";
}
void push()
{
if(top==size-1)
cout<<"Stack Overflow"<>stack[top];
}
}
void pop()
{
if(top==-1)
cout<<"Stack underflow"<=0;i--)
cout<<" "<>size;
do
{
cin>>o;
switch(o)
{
case 1:
{
push();
break;
}
case 2:
{
pop();
break;
}
}
cin>>opt;
}while(opt=='y');
print();
return 0;
}
#include
ReplyDeleteusing namespace std;
int stack[100], top=-1, size;
void push(int &top,int n)
{
cout <<"";
}
void push()
{
if(top==size-1)
cout<<"Stack Overflow"<>stack[top];
}
}
void pop()
{
if(top==-1)
cout<<"Stack underflow"<=0;i--)
cout<< " " <>size;
do
{
cin>>o;
switch(o)
{
case 1:
{
push();
break;
}
case 2:
{
pop();
break;
}
}
cin>>opt;
}while(opt=='y');
print();
return 0;
}
100% execution
Delete#include
ReplyDeleteusing namespace std;
struct node{
int data;
struct node *next;
}*head=NULL,*temp,*newNode;
void create(){
newNode=(struct node *)malloc(sizeof(struct node));
cin>>newNode->data;
newNode->next=head;
head=newNode;
}
void push(int &top,int n);
void pop(){
temp=head;
cout<<"deleted element is"<data<<" ";
temp=temp->next;
}
}
int main() {
int b,a;
cin>>a;
char c='y';
while(c=='y'){
int b;
cin>>b;
if(b==1){
create();
}
else if(b==2){
pop();
}
cin>>c;
}
return 0;
}
here's the fix:
ReplyDeletecout<<"deleted element is"<<endl<<stack[top];
line 24
ReplyDelete