Advertisement
IonutCava

simple calc

Jan 7th, 2015
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. void calc(float x, float y, char operation, float& result)
  2. {
  3.  
  4. switch (operation)
  5. {
  6. case '+':
  7. result = x + y;
  8. return;
  9.  
  10. case '-':
  11. result = x - y;
  12. return;
  13.  
  14. case '*':
  15. result = x * y;
  16. return;
  17.  
  18. case '/':
  19. VERIFICA SA NU FIE y == 0
  20. result = x / y;
  21. return;
  22.  
  23. default:
  24. EROARE PE AICI
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement