Advertisement
Guest User

Untitled

a guest
Mar 29th, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. float dzialanie(float a, char oper, float b);
  5. int main()
  6. {
  7. float a, b;
  8. char oper;
  9.  
  10.  
  11.  
  12. cout << "Podaj dwie liczby z operatorem";
  13.  
  14. if (cin >> a >> oper >> b)
  15. dzialanie(a, oper, b);
  16.  
  17. return 0;
  18. }
  19.  
  20. float dzialanie(float a, char oper, float b)
  21. {
  22. switch(oper) {
  23. case '+':
  24. cout << "\nWynik: " << (a + b);
  25. break;
  26. case '-':
  27. cout << "\nWynik: " << (a - b);
  28. break;
  29. case '*':
  30. cout << "\nWynik: " << (a * b);
  31. break;
  32. case '/':
  33. cout << "\nWynik: "<< (a / b);
  34. break;
  35. default:
  36. cout << "\nnieprawidłowy operator";
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement