grodek118

Kalkulator

Jul 2nd, 2020
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int x , y, obliczenie;
  8.  
  9. cout << "Podaj pierwsza liczbe: " << endl;
  10. cin >> x;
  11.  
  12. do{
  13. cout << "Podaj rodzaj operacji: \n(1)dodawanie \n(2)odejmowanie \n(3)mnozenie \n(4)dzielenie \n(5)modulo \n(0)wyjscie" << endl;
  14. cin >> obliczenie;
  15.  
  16. switch(obliczenie)
  17. {
  18. case 1:
  19. cout << "Podaj druga liczbe: " << endl;
  20. cin >> y;
  21. x += y;
  22. cout << x << endl;
  23. break;
  24.  
  25. case 2:
  26. cout << "Podaj druga liczbe: " << endl;
  27. cin >> y;
  28. x -= y;
  29. cout << x << endl;
  30. break;
  31.  
  32. case 3:
  33. cout << "Podaj druga liczbe: " << endl;
  34. cin >> y;
  35. x *= y;
  36. cout << x << endl;
  37. break;
  38.  
  39. case 4:
  40. cout << "Podaj druga liczbe: " << endl;
  41. cin >> y;
  42. x /= y;
  43. cout << x << endl;
  44. break;
  45.  
  46. case 5:
  47. cout << "Podaj druga liczbe: " << endl;
  48. cin >> y;
  49. x %= y;
  50. cout << x << endl;
  51. break;
  52.  
  53. // case 6:
  54. // x = 0;
  55. // break;
  56. }
  57.  
  58. }while(obliczenie != 0);
  59.  
  60. }
Advertisement
Add Comment
Please, Sign In to add comment