Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- float dzialanie(float a, char oper, float b);
- int main()
- {
- float a, b;
- char oper;
- cout << "Podaj dwie liczby z operatorem";
- if (cin >> a >> oper >> b)
- dzialanie(a, oper, b);
- return 0;
- }
- float dzialanie(float a, char oper, float b)
- {
- switch(oper) {
- case '+':
- cout << "\nWynik: " << (a + b);
- break;
- case '-':
- cout << "\nWynik: " << (a - b);
- break;
- case '*':
- cout << "\nWynik: " << (a * b);
- break;
- case '/':
- cout << "\nWynik: "<< (a / b);
- break;
- default:
- cout << "\nnieprawidłowy operator";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement