Rechner.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include <stdio.h>
  2. int main() {
  3. char trigger = 'j';
  4. while (trigger == 'j')
  5. {
  6. int a;
  7. int b;
  8. char operation;
  9. printf("Gib die Rechnoperation ein (+,-,*,/): ");
  10. scanf(" %c", &operation);
  11. printf("Bitte eine a eingeben: ");
  12. scanf("%d",&a);
  13. printf("Bitte eine zweite a eingeben: ");
  14. scanf("%d", &b);
  15. if (operation == '+')
  16. {
  17. int sum = a + b;
  18. printf("Ergebnis: %d", sum);
  19. }
  20. else if (operation == '-')
  21. {
  22. int sum = a - b;
  23. printf("Ergebnis: %d", sum);
  24. }
  25. else if (operation == '*')
  26. {
  27. int sum = a * b;
  28. printf("Ergebnis: %d", sum);
  29. }
  30. else if (operation == '/')
  31. {
  32. float sum = a / b;
  33. printf("Ergebnis: %d", sum);
  34. }
  35. printf("\n");
  36. printf("Möchtest du eine weitere Berechnung durchführen? (j/n): ");
  37. scanf(" %c", &trigger);
  38. }
  39. }