Guest User

Untitled

a guest
Oct 18th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void rechnen(int art, int x, int y) {
  5.     switch(art) {
  6.     case 1:
  7.         cout << "Das Ergebniss ist: " << x+y << endl;
  8.         break;
  9.     case 2:
  10.         cout << "Das Ergebniss ist: " << x-y << endl;
  11.         break;
  12.     case 3:
  13.         cout << "Das Ergebniss ist: " << x*y << endl;
  14.         break;
  15.     case 4:
  16.         cout << "Das Ergebniss ist: " << x/y << endl;
  17.         break;
  18.     default:
  19.         cout << "Falsche Eingabe." << endl;
  20.         break;
  21.     }
  22.    
  23.    
  24.    
  25.    
  26. }
  27.  
  28. int main() {
  29.    
  30.     cout << "Geben Sie die Rechenart ein\n(1 = +, 2 = -, 3 = *, 4 = /): ";
  31.     int bla;
  32.     cin >> bla;
  33.     cout << endl;
  34.    
  35.     cout << "Geben Sie die erste Ziffer ein: ";
  36.     int x;
  37.     cin >> x;
  38.     cout << endl;
  39.  
  40.     cout << "Geben Sie die zweite Ziffer ein: ";
  41.     int y;
  42.     cin >> y;
  43.     cout << endl;
  44.  
  45.  
  46.     rechnen(bla, x, y);
  47.  
  48.     system("PAUSE");
  49.  
  50.    
  51. }
Add Comment
Please, Sign In to add comment