Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
Anonymous
unregistriert
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
#include <iostream> using namespace std; int main () { float fzahl1, fzahl2, fergebnis; char addition = "addition"; char subtraktion = "subtraktion"; char multiplikation = "multiplikation"; char division = "division"; char operation; cout << "Geben Sie bitte eine Zahl an.\n"; cin >> fzahl1; cout << "Bitte geben Sie die gewünschte Operation ein:\n"; cin >> operation; cout << "Nun geben Sie bitte eine zweite Zahl an, mit der Sie rechnen möchten.\n"; cin >> fzahl2; if (operation == addition) { fergebnis = fzahl1 + fzahl2; cout << "\nErgebnis: " << fergebnis << endl; } else cout << "Keine gültigen Zahlen und/oder Operationen.\n"; if (operation == subtraktion) { fergebnis = fzahl1 - fzahl2; cout << "\nErgebnis: " << fergebnis << endl; } else cout << "Keine gültigen Zahlen und/oder Operationen.\n"; if (operation == multiplikation) { fergebnis = fzahl1 * fzahl2; cout << "\nErgebnis: " << fergebnis << endl; } else cout << "Keine gültigen Zahlen und/oder Operationen.\n"; if (operation == division) { fergebnis = fzahl1 / fzahl2; cout << "\nErgebnis: " << fergebnis << endl; } else cout << "Keine gültigen Zahlen und/oder Operationen.\n"; return 0; } |
Anonymous
unregistriert
C-/C++-Quelltext |
|
1 |
char addition = "addition"; |
C-/C++-Quelltext |
|
1 |
char addition[] = "addition"; |
C-/C++-Quelltext |
|
1 |
char *addition = "addition"; |
C-/C++-Quelltext |
|
1 |
char addition = "addition"; |
C-/C++-Quelltext |
|
1 |
char dummy = 'A'; |
Anonymous
unregistriert
Anonymous
unregistriert
Anonymous
unregistriert
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
if (operation == addition) { fergebnis = fzahl1 + fzahl2; cout << "\nErgebnis: " << fergebnis << endl; } else cout << "Keine gültigen Zahlen und/oder Operationen.\n"; if (operation == subtraktion) { fergebnis = fzahl1 - fzahl2; cout << "\nErgebnis: " << fergebnis << endl; } else cout << "Keine gültigen Zahlen und/oder Operationen.\n"; if (operation == multiplikation) { fergebnis = fzahl1 * fzahl2; cout << "\nErgebnis: " << fergebnis << endl; } else cout << "Keine gültigen Zahlen und/oder Operationen.\n"; if (operation == division) { fergebnis = fzahl1 / fzahl2; cout << "\nErgebnis: " << fergebnis << endl; } else cout << "Keine gültigen Zahlen und/oder Operationen.\n"; return 0; |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
if (operation == addition) { fergebnis = fzahl1 + fzahl2; std::cout << "\nErgebnis: " << fergebnis << std::endl; } else if (operation == subtraktion) { fergebnis = fzahl1 - fzahl2; std::cout << "\nErgebnis: " << fergebnis << std::endl; } else if (operation == multiplikation) { fergebnis = fzahl1 * fzahl2; std::cout << "\nErgebnis: " << fergebnis << std::endl; } else if (operation == division) { fergebnis = fzahl1 / fzahl2; std::cout << "\nErgebnis: " << fergebnis << std::endl; } else std::cout << "Keine gültigen Zahlen und/oder Operationen.\n"<< std::endl; |
Anonymous
unregistriert
Anonymous
unregistriert
Zitat von »"nix da"«
C-/C++-Quelltext
1 char *addition = "addition";
C-/C++-Quelltext |
|
1 |
const char *addition = "addition"; |
Werbeanzeige