Advertisement
Guest User

d2

a guest
Nov 28th, 2014
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void Addition(){
  6.     int pl;
  7.     int ck;
  8.     int sum;
  9.  
  10.     cout << "Please enter a number!" << endl;
  11.     cin >> pl;
  12.  
  13.     cout << "Please enter a second number!" << endl;
  14.     cin >> ck;
  15.  
  16.     sum = pl + ck;
  17.  
  18.     cout << "The sum of these two numbers is " << sum << " !!!" << endl;
  19.  
  20. }
  21.  
  22. void Subtraction(){
  23.     int lp;
  24.     int kc;
  25.     int diff;
  26.  
  27.     cout << "Please enter a number!" << endl;
  28.     cin >> lp;
  29.  
  30.     cout << "Please enter a second number!" << endl;
  31.     cin >> kc;
  32.  
  33.     diff = lp - kc;
  34.  
  35.     cout << "The difference is " << diff << " !!!" << endl;
  36.  
  37. }
  38.  
  39. int main()
  40. {
  41.     int a;
  42.  
  43.     cout << "Type 1 for Addition or 2 for subtraction" << endl;
  44.     cin >> a;
  45.  
  46.     if(a == 1) {
  47.         Addition();
  48.     }else{
  49.         Subtraction();
  50.     }
  51.  
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement