Calculator Enum

Medium Enumerations & Typedef
Solve in Playground →

Problem Statement

Write a C program using an enum representing operations (ADD=1, SUB=2, MUL=3, DIV=4) to compute expressions.

Input Format

Operation code (1-4) followed by two integers A and B.

Output Format

Print the calculation result.

Constraints

1 <= Op <= 4, -1000 <= A, B <= 1000

Sample Input

1 10 20

Sample Output

30

Explanation

Operation 1 (ADD) on 10 and 20 gives 30.

Starter Code

#include <stdio.h>

enum Operation { ADD = 1, SUB, MUL, DIV };

int main() {
    int op, a, b;
    if (scanf("%d %d %d", &op, &a, &b) == 3) {
        // 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