Hi,
ich habe versucht in c++ einen Taschenrechner zu programmieren.
Soweit so gut wie es dann bei sowas fast immer ist, wenn man es das erste Mal macht , es geht nicht :(.
Ich weiß einfach nicht woran es liegen kann hier ma mein code:
hoffe ihr könnt mir helfen :handsdown:
mfg
ich habe versucht in c++ einen Taschenrechner zu programmieren.
Soweit so gut wie es dann bei sowas fast immer ist, wenn man es das erste Mal macht , es geht nicht :(.
Ich weiß einfach nicht woran es liegen kann hier ma mein code:
Code:
#include<iostream>
using namespace std;
int main()
{
int plus=1;
int minus=2;
int mal=3;
int geteilt=4;
int auswahl;
int zahl1;
int zahl2;
int ergebnis;
cout<<"Was wollen sie rechnen? Plus(1), Minus(2), Mal(3), Geteilt(4).\n";
cin>>auswahl;
cout<<"Gebe sie die erste Zahl ein.\n";
cin>>zahl1;
cout<<"Gebe sie die zweite Zahl ein.\n";
cin>>zahl2;
if(auswahl==plus)
{
ergebnis=zahl1+zahl2;
cout<<"Das Ergebnis ist"<<ergebnis;
}
else(auswahl==minus)
{
ergebnis=zahl1-zahl2;
cout<<"Das Ergebnis ist"<<ergebnis;
}
else(auswahl==mal)
{
ergebnis=zahl1*zahl2;
cout<<"Das Ergebnis ist"<<ergebnis;
}
else(auswahl==geteilt)
{
ergebnis=zahl1/zahl2;
cout<<"Das Ergebnis ist"<<ergebnis;
}
}
mfg