#include <iostream>
using namespace std;
#define size 10
int stack[10];
int top = -1;
void push(int value){
    if (top == size - 1){
        cout << "the stack is full" << endl;
    } else {
        top++;
        stack[top] = value;
    }
}
int pop(){
    if (top == -1){
        cout << "the stack is empty" << endl;
        return 0;
    } else {
        return stack[top--];
    }
}
int main() {
    int i = 0;
    while (i < size){
         push(i++);
    }
    int j = pop();
    cout << j << endl;
    j = pop();
     cout << j << endl;
    return 0;
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: