Traffic Signal

Easy Enumerations & Typedef
Solve in Playground →

Problem Statement

Write a C program using an enum for traffic signals (RED=0, YELLOW=1, GREEN=2) and read an integer input to print the matching state message.

Input Format

An integer (0, 1, or 2).

Output Format

Print 'Stop' for 0, 'Ready' for 1, 'Go' for 2, or 'Invalid' otherwise.

Constraints

0 <= Input <= 2

Sample Input

2

Sample Output

Go

Explanation

Signal 2 corresponds to GREEN state ('Go').

Starter Code

#include <stdio.h>

enum Signal { RED, YELLOW, GREEN };

int main() {
    int val;
    if (scanf("%d", &val) == 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