Menu
Coddy logo textTech

Grundrechenarten

Teil des Abschnitts Grundlagen der C++-Journey von Coddy — Lektion 40 von 74.

challenge icon

Aufgabe

Anfänger

Fügen Sie die grundlegenden arithmetischen Operationen (Addition, Subtraktion, Multiplikation und Division) für num1 und num2 hinzu. Speichern Sie die Ergebnisse in Variablen mit den Namen sum, difference, product bzw. division. Geben Sie die Ergebnisse mit std::cout im folgenden Format auf der Konsole aus:

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

Probier es selbst

#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;
}

Alle Lektionen in Grundlagen