#include <iostream>
using namespace std;

const int Size = 10;
int top = -1;
int stack[Size];

void push(int value)
{
    if (top == Size - 1)
    {
        cout << "Stack Overflow\n";
    }
    else
    {
        stack[++top] = value;
    }
}

void display()
{
    if (top == -1)
    {
        cout << "Stack is Empty\n";
        return;
    }

    cout << "Stack Values Are:\n";

    for (int i = top; i >= 0; i--)
    {
        cout << stack[i] << endl;
    }
}

void pop()
{
    if (top == -1)
    {
        cout << "Stack is Empty\n";
    }
    else
    {
        cout << stack[top--] << endl;
    }
}

void peek()
{
    if (top == -1)
    {
        cout << "Stack is Empty\n";
    }
    else
    {
        cout << "Peek is = " << stack[top] << endl;
    }
}

int main()
{
    push(10);
    push(20);
    push(30);
    push(40);

    display();

    pop();
    pop();

    peek();

    pop();
    pop();
    pop();
}