You are on page 1of 2

1: #include<iostream>

2: using namespace std;


3: class Stack_LL{
4: int array[10];
5: int Top = -1;
6: public:
7: void push(int valu)
8: {
9: Top++;
10: if(Top<10)
11: {
12: array[Top] = valu;
13: }
14: else
15: {
16: cout<<"Stack is Full";
17: Top--;
18: }
19: }
20: int top(){
21: if(Top >= 0 )
22: return array[Top];
23: else
24: {
25: cout<<"Stack is empty";
26: return 0;
27: }
28:
29: }
30: void pop()
31: {
32: if(Top>0)
33: Top = Top-1;
34: }
35: bool isEmpty()
36: {
37: if(Top < 0 )
38: return true;
39: }
40: };
41: int main()
42: {
43: Stack_LL obj1;
44: obj1.push(100);
45: obj1.push(200);
46: cout<<obj1.top()<<endl;
47: obj1.pop();
48: cout<<obj1.top()<<endl;
49: obj1.pop();
50: if(obj1.isEmpty())
51: {
52: cout<<"Yes! Stack is empty\n";
53: }
54:
55:
56: }

You might also like