Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons

© 2026 BraveProgrammer. All rights reserved.

  1. Courses
  2. /
  3. C Programming Fundamentals

Lesson 31 of 50 · c

Stacks (LIFO) Using Arrays

Duration: 10 mins

A stack follows last‑in‑first‑out order. Implemented easily with a fixed‑size array and an integer index.

#define MAX 100
int stack[MAX];
int top = -1; // empty stack

void push(int x) { if (top < MAX-1) stack[++top] = x; }
int pop(void) { if (top >= 0) return stack[top--]; return -1; }
Previous: Dynamic Data Structures – Doubly Linked ListNext: Queues (FIFO) Using Circular Buffers