Stack Using Array

Medium Algorithmic Challenges
Solve in Playground →

Problem Statement

Write a C program to implement a Stack using an array supporting push and pop operations.

Input Format

Number of operations Q, followed by queries ('P x' for push x, 'O' for pop).

Output Format

Print popped elements, or 'Stack Empty' if popping from empty stack.

Constraints

1 <= Q <= 100

Sample Input

5
P 10
P 20
O
P 30
O

Sample Output

20
30

Explanation

Pushes 10 and 20, pops 20 (LIFO), pushes 30, pops 30.

Starter Code

#include <stdio.h>

int main() {
    int q;
    if (scanf("%d", &q) == 1) {
        // Write your code here
    }
    return 0;
}

Limits

  • Time Limit: 1s
  • Memory Limit: 256MB

Embedded C Programming

Updated: March 15, 2026
Intermediate

Embedded systems rely on efficient low-level programming to interact directly with hardware. In this course, you will learn how to write practical Embedded C programs used in real microcontroller-based systems. Rather than focusing only on theory, this course follows a practice-driven approach. Each lesson includes hands-on coding exercises that simulate real firmware development tasks used