Menu
Coddy logo textTech

Basic Operations

Part of the Fundamentals section of Coddy's C++ journey — lesson 40 of 74.

challenge icon

Challenge

Beginner

Add the basic arithmetic operations (addition, subtraction, multiplication, and division) on num1 and num2. Store the results in variables named sum, difference, product, and division, respectively. Print the results to the console using std::cout in the following format:

Sum: [sum]
Difference: [difference]
Product: [product]
Division: [division]

Try it yourself

#include <iostream>

int main() {
    std::cout << "Calculator App" << std::endl;

    // Get input from the user
    double num1;
    std::cin >> num1;
    double num2;
    std::cin >> num2;

    // Print the numbers
    std::cout << "First number: " << num1 << std::endl;
    std::cout << "Second number: " << num2 << std::endl;

    return 0;
}

All lessons in Fundamentals