#include <stdio.h>

int stack[100];
int top = -1;

void push(int x){
    stack[++top] = x;
}

void pop(){
    top--;
}

int main(){
    int arr[] = {'A','B','C','D','E','F','G'};

    for(int i = 0; i < 7; i++){
        if(top == 4){
            for(int i = 0; i < 4; i++){
                stack[i] = stack[i + 1];
            }
            pop();
        }
        else{
            push(arr[i]);
        }
    }
    for(int i = 0; i <= 7; i++){
        printf("%c ", stack[i]);
    }

    return 0;
}

Embed on website

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