Calculator

Medium Functions
Solve in Playground →

Problem Statement

Write a C++ program defining separate functions for addition, subtraction, multiplication, and division, and invoke them based on an operator symbol.

Input Format

Two numbers A and B, followed by operator character OP.

Output Format

Print result formatted to 2 decimal places, or 'Error: Division by zero'.

Constraints

OP is +, -, *, /

Sample Input

10.0 5.0 +

Sample Output

15.00

Explanation

Modularizes arithmetic calculations into specialized function routines.

Starter Code

#include <iostream>
#include <iomanip>

// Define calculation functions here

int main() {
    double a, b;
    char op;
    if (std::cin >> a >> b >> op) {
        // Invoke appropriate function and print result
    }
    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