Certainly! Here's an example program in C that implements a stack data structure using an array:
#include <stdio.h>

#define MAX_SIZE 100

typedef struct {
    int arr[MAX_SIZE];
    int top;
} Stack;

void initialize(Stack *stack) {
    stack->top = -1;
}

int isEmpty(Stack *stack) {
    return stack->top == -1;
}

int isFull(Stack *stack) {
    return stack->top == MAX_SIZE - 1;
}

void push(Stack *stack, int data) {
    if (isFull(stack)) {
        printf("Stack Overflow: Cannot push element, stack is full.\n");
    } else {
        stack->arr[++stack->top] = data;
    }
}

int pop(Stack *stack) {
    if (isEmpty(stack)) {
        printf("Stack Underflow: Cannot pop element, stack is empty.\n");
        return -1; // Return a default value indicating failure
    } else {
        return stack->arr[stack->top--];
    }
}

int peek(Stack *stack) {
    if (isEmpty(stack)) {
        printf("Stack is empty.\n");
        return -1; // Return a default value indicating failure
    } else {
        return stack->arr[stack->top];
    }
}

int main() {
    Stack stack;
    initialize(&stack);

    push(&stack, 10);
    push(&stack, 20);
    push(&stack, 30);

    printf("Top element: %d\n", peek(&stack));

    printf("Popped element: %d\n", pop(&stack));
    printf("Popped element: %d\n", pop(&stack));

    printf("Top element: %d\n", peek(&stack));

    return 0;
}

This program defines a stack using a structure called Stack, which contains an array arr to store the elements and a variable top to keep track of the top element. The functions initialize, isEmpty, isFull, push, pop, and peek are implemented to perform various operations on the stack.

In the main function, the stack is initialized, elements are pushed onto the stack using the push function, and then popped using the pop function. The peek function is used to retrieve the top element without removing it. Finally, the program displays the top element of the stack.

Please note that this is a basic implementation of a stack and does not include error handling for all possible scenarios. You can enhance the program further based on your requirements.
spam fails_task lang_mismatch pii not_appropriate hate_speech sexual_content quality toxicity humor helpfulness creativity violence