A stack is a Last-In-First-Out (LIFO) data structure where elements are added and removed from the same end, called the top. Think of it like a stack of plates - you can only add or remove from the top.
// Stack implementation using array#define MAX_SIZE 100struct Stack {int items[MAX_SIZE];int top;};// Push operationvoid push(struct Stack* stack, int value) {if (stack->top == MAX_SIZE - 1) {printf("Stack overflow\n");return;}stack->items[++stack->top] = value;}// Pop operationint pop(struct Stack* stack) {if (stack->top == -1) {printf("Stack underflow\n");return -1;}return stack->items[stack->top--];}
made by billy | source code | @b9llach