Untitled

 avatar
gulamsakaria2025
plain_text
21 days ago
653 B
4
Indexable
#include <bits/stdc++.h>
using namespace std;
const int maxt = 100;
int top = -1;
int mystack[maxt];

void push()
{
    if (top == maxt - 1)
    {

        cout << "Overflow";
        return;
    }
    int x;
    cin >> x;
    top++;
    mystack[top] = x;
}
void pop()
{
    if (top == -1)
    {
        cout << "  Underflow ";
        return;
    }
    top--;
}
void display()
{
    if (top == -1)
    {
        cout << " Empty ";
        return;
    }
    for (int i = top; i > -1 ; i--)
    {
        cout << mystack[i] << " ";
    }
    cout << endl;
}

int main()
{
    push();
    
    display();
}
Editor is loading...
Leave a Comment