Circular Queue Simulation

Medium Circular Queue PRO
🔒 Login to Unlock

Problem Statement

Write a C program to simulate complex transactions on a fixed-size circular queue and print the final queue state.

Input Format

Capacity and number of queries. Subsequent lines contain query codes (1 for enqueue, 0 for dequeue).

Output Format

Print remaining elements from front to rear separated by spaces.

Constraints

1 <= capacity <= 50, 1 <= queries <= 100

Sample Input

4 6
1 10
1 20
1 30
0
1 40
1 50

Sample Output

20 30 40 50

Explanation

Process enqueues and dequeues sequentially using circular array indexing formulas.

Starter Code

#include <stdio.h>
#include <stdlib.h>

int main() {
    int cap, queries;
    if (scanf("%d %d", &cap, &queries) == 2) {
        // Write your code here for circular queue simulation
    }
    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