2019-Cpe-27 DS&a Lab Manual #07
2019-Cpe-27 DS&a Lab Manual #07
Lab Manual # 07
Lab Submission[10] 0 1 2 3 4 5
Completeness & Correctness
Required Conclusion & Results
No of Checks
SUB TOTAL
TOTAL SCORE
Course Instructor
For example, you have a stack of trays on a table. The tray at the top of the stack is the first
item to be moved if you require a tray from that stack.
Stacks have restrictions on the insertion and deletion of elements. Elements can be inserted or
deleted only from one end of the stack i.e. from the top. The element at the top is called
the top element. The operations of inserting and deleting elements are
called push() and pop() respectively.
When the top element of a stack is deleted, if the stack remains non-empty, then the element
just below the previous top element becomes the new top element of the stack.
For example, in the stack of trays, if you take the tray on the top and do not replace it, then the
second tray automatically becomes the top element (tray) of that stack.
Features of stacks
int n;
cout<<"Given Stack\n";
push(ar);
repeat:
cout<<"\nEnter 1 for delete\nEnter 2 for Show\n\nEnter Your Selection: ";
cin>>n;
if(n==1)
{
pop(ar);
goto repeat;
}
else if(n==2)
{
show(ar);
}
else
{
cout<<"Invalid Selection\n";
}
return 0;
}
Paste your output here