Guest User

Untitled

a guest
Apr 27th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. int main()
  2. {
  3. cout<<"10+20"<<calc(10,20,+);
  4. cout<<"10*20"<<calc(10,20,*);
  5. cout<<"10-20"<<calc(10,20,-);
  6. cout<<"10/20"<<calc(10,20,/);
  7.  
  8. }
  9.  
  10. int calc (int a, int b, char c)
  11. {
  12. int total=0;
  13. if(c=='+'){
  14. total = a+b;
  15. }else if(c=='*'){
  16. total = a*b;
  17. }else if(c=='-'){
  18. total = a-b;
  19. }else if(c=='/'){
  20. total = a/b;
  21. }
  22. return total;
  23. }
Add Comment
Please, Sign In to add comment