Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- int secondary(int argc, char* argv[])
- {
- std::cout << "calculator" << std::endl; \
- std::cout << "Vill du räkna 'division', 'multiplikation', 'addition' eller 'subtraktion'?"; \
- }
- #define Func(str, check, print, op) \
- if(a, b != int or double)
- {
- std::cout << "Can only calculate INT" << std::endl; \
- }
- if(str == check) \
- { \
- std::cout << "Skriv vad som skall " << print << std::endl; \
- std::cin >> a >> b; \
- if (check == "division") \
- { \
- std::cout << a op b << std::endl; \
- std::cout << a op b * 100 + "%"; \
- else \
- std::cout << a op b << std::endl; \
- }
- }
- int main(int argc, char* argv[])
- {
- double a, b;
- std::string c;
- std::cin >> c;
- {
- Func(c, "multiplikation", "multipliceras", *)
- else
- Func(c, "addition", "adderas", +)
- else
- Func(c, "subtraktion", "subtraheras", -)
- else
- Func(c, "division", "divideras", /)
- }
- system("PAUSE");
- return 0;
- }
- #undef Func
Add Comment
Please, Sign In to add comment