Advertisement
Guest User

Calculator Code

a guest
Jul 29th, 2014
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int a;
  8. int b;
  9. int c;
  10.  
  11. cout << "Will you be adding(1), subtracting(2), multiplying(3) or dividing(4)? " << endl;
  12. cin >> c;
  13.  
  14. cout << "Enter a number " << endl;
  15. cin >> a;
  16.  
  17. cout << "Enter another number " << endl;
  18. cin >> b;
  19.  
  20. if(c==1){
  21. cout << "The answer is " << a+b << endl;
  22. }
  23. if(c==2){
  24. cout << "The answer is " << a-b << endl;
  25. }
  26. if(c==3){
  27. cout << "The answer is " << a*b << endl;
  28. }
  29. if(c==4){
  30. cout << "The answer is " << a/b << endl;
  31. }
  32.  
  33.  
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement