Hilfe beim Taschenrechner :)



  • Hallo ,
    ich hab jetzt neu angefangen mit C++ zu programmieren und hab mich an einen Taschenrechner ran gemacht.
    Jetzt hab ich leider das Problem dass wenn er eigentlich die Aufgabe ausrechnen soll kein Ergebniss kommt.
    Ich hoffe ihr könnt mir helfen und danke schonmal im Vorraus 😃
    Das ist mein Code:

    #include <iostream>

    using namespace std;

    void addition(float zahl_1, float zahl_2);
    void subtraktion(float zahl_1, float zahl_2);
    void multiplikation(float zahl_1, float zahl_2);
    void dividirn (float zahl_1, float zahl_2);

    int main(void)
    {

    char eingabe;
    float zahl_1, zahl_2;

    cout << "Zahl 1 eingeben: ";
    cin >> zahl_1;
    cout << "Zahl 2 eingeben: ";
    cin >> zahl_2;
    cout << "1 = Addiren \n2 = Subtrahieren \n3 = Multiplizieren \n4 = Dividieren \n";

    if ( eingabe == 1 ) {
    addition(zahl_1, zahl_2) ;

    }else if ( eingabe == 2 ) {
    subtraktion(zahl_1, zahl_2);

    }else if ( eingabe == 3 ) {
    multiplikation(zahl_1, zahl_2);

    }else if ( eingabe == 4 ) {
    dividirn(zahl_1, zahl_2);
    }

    cin.sync();
    cin.get();
    return 0;
    }

    void addition(float a, float b)
    {
    cout << a + b;
    }

    void subtraktion(float a, float b)
    {
    cout << a - b;
    }

    void multiplikation(float a, float b)
    {
    cout << a * b;
    }

    void dividirn(float a, float b)
    {
    cout << a / b;
    }



  • Fehlt da nicht irgendwo ein

    cin >> eingabe;
    

    ?



  • Danke es hat geklappt 🙂


Anmelden zum Antworten