Aktueller Stand:
PHP Code:
// if2.cpp
#include <iostream>
#include <cstdlib>
using namespace std;
int main(void) {
int var;
cout << "[0] Ich will zu if\n";
cout << "\nIhre Wahl bitte : ";
if( (cin >> var) == false ) {
cerr << "Fehler bei der Eingabe!\n";
exit(1);
}
if( var == 0 ) {
cout << "Du hast if gewählt!\n";
}
else {
cout << "Du hast nicht [0] gewählt daher else\n";
}
return 0;
}
hoffe da war kein tipp-fehler drinn.
stimmt das so?
Ausgeführt will ich das bezwecken:
Quote:
[o] Ich will zu if
[1-9] Ich will zu else
Ihre Wahl bitte: 0
Du hast if gewählt!
[0] Ich will zu if
[1-9] Ich will zu else
Ihre Wahl bitte : 6
Du hast nicht [0] gewählt daher else.
|
Jetz hab ich da noch ne frage könnt ich theoretisch auch:
PHP Code:
#include <iostream>
using namespace std;
int main(void) {
long double wert;
cout<< "Bitte eine Zahl :";
cin >> wert;
cout << "Die Eingabe war " << wert << '\n';
return 0;
}
einschreiben um nicht:
Quote:
|
Du hast nicht [0] gewählt daher else.
|
zu schreiben sondern um:
Quote:
|
Du hast << wert << eingegeben daher if/else.
|
Danke für eure tolle Hilfe.
Ich selbst finde dass ich bereits gute Vortschritte mache.