Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. // ConsoleApplication1.cpp : Definiert den Einstiegspunkt für die Konsolenanwendung.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <stdlib.h>
  6.  
  7. int main()
  8. {
  9. int zahl1;
  10. int zahl2;
  11. char rechenoperator;
  12. int ergebnis;
  13.  
  14. printf("1. Zahl?\n");
  15. do { scanf_s("%i", &zahl1); } while (getchar() != '\n');
  16.  
  17. printf("Rechenoperator?\n");
  18. do { scanf_s("%c", &rechenoperator); } while (getchar() != '\n');
  19.  
  20. printf("2. Zahl?\n");
  21. scanf_s("%i", &zahl2);
  22.  
  23. do { printf("%c", rechenoperator); } while (getchar() != '\n');
  24.  
  25. switch (rechenoperator) {
  26. case '+': printf("Ergebnis: %d", zahl1 + zahl2); break;
  27. case '-': printf("Ergebnis: %d", zahl1 - zahl2); break;
  28. case '*': printf("Ergebnis: %d", zahl1 * zahl2); break;
  29. case '/': printf("Ergebnis: %d", zahl1 / zahl2); break;
  30. default: printf("Kein gültiges Rechenzeichen"); break;
  31. }
  32.  
  33. system("PAUSE");
  34.  
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement