PUSH AND POP IN ARRAY

PUSH AND POP ARRAY




#include<iostrem>
#include<conio>
#include<stdib>
 void push (int);
void main()
{clrscr();
int ar[10],x,u=9,1=0,tos=-1,opt;
while(1)
{cout<<"\nfor PUSH enter 1,for POP enter 2,to exit enter 3:";
cin>>opt;
if(opt==1)
cout<<"Enter the value to be pushed";
cin>>n;
if(tos==n)
{cout<<"\ns trsck full";
getch();
}
else
{tos++;
ar[tos]=n;
cout<<"\n value inserted successfully";
}
else if(opt==2){if(tos<1)
{cout<<"\n stack empty ";
getch();
else
{x=ar[tos];
tos--;
cout<<"\n value"<<x<<"Delated succesfully";
}
}
else{
cout<<"\nThank you";
getch();
exit(0);

}
}
}

Comments