/*push in stack*/
#include<iostream.h>
#include<conio.h> /*for clrscr*/
#include<stdlib.h> /*for exit*/
void main()
{
clrscr();
int stack[10],top=-1,size,value;
char choice;
cout<<"Enter the size if element ";
cin>>size;
do
{
if(top==(size-1))
{ cout<<"overflow";
exit(0);
}
cout<<"\nEnter the value ";
cin>>value;
++top;
stack[top]=value;
for(choice=top;choice>=0;choice--)
cout<<"\n\n\Your stack........... "<<stack[choice];
cout<<endl;
cout<<"\n\n Do you want to continue press(1) ";
cin>>choice;
}while(choice=='1');
}
#include<iostream.h>
#include<conio.h> /*for clrscr*/
#include<stdlib.h> /*for exit*/
void main()
{
clrscr();
int stack[10],top=-1,size,value;
char choice;
cout<<"Enter the size if element ";
cin>>size;
do
{
if(top==(size-1))
{ cout<<"overflow";
exit(0);
}
cout<<"\nEnter the value ";
cin>>value;
++top;
stack[top]=value;
for(choice=top;choice>=0;choice--)
cout<<"\n\n\Your stack........... "<<stack[choice];
cout<<endl;
cout<<"\n\n Do you want to continue press(1) ";
cin>>choice;
}while(choice=='1');
}
No comments:
Post a Comment