Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.38 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. //equation to be done in the main
  6. void AdditionEq(){
  7.     int a, b, sum;
  8.     cout<< "Please enter the 1st integer: ";
  9.     cin>> a;
  10.     cout<< "Please enter the 2nd integer: ";
  11.     cin>> b;
  12.     sum=a+b;
  13.     cout<< "The result is: " <<sum<<endl;
  14. }
  15.  
  16. void SubtractionEq(){
  17.     int a, b, diff;
  18.     cout<< "Please enter the 1st integer: ";
  19.     cin>> a;
  20.     cout<< "Please enter the 1st integer: ";
  21.     cin>> b;
  22.     diff=a-b;
  23.     cout<< "The result is: " <<diff<<endl;
  24. }
  25.  
  26. void DivisionEq(){
  27.     int a, b, quad;
  28.     cout<< "Please enter the 1st integer: ";
  29.     cin>> a;
  30.     cout<< "Please enter the 2nd integer: ";
  31.     cin>> b;
  32.     quad=a/b;
  33.     cout<< "The result is: " <<quad<<endl;
  34. }
  35.  
  36. void MultiplicationEq(){
  37.     int a, b, pro;
  38.     cout<< "Please enter the 1st integer: ";
  39.     cin>> a;
  40.     cout<< "Please enter the 1st integer: ";
  41.     cin>> b;
  42.     pro=a*b;
  43.     cout<< "The result is: " <<pro<<endl;
  44. }
  45.  
  46. int main()
  47. {
  48.    //Options for user
  49.    char opt;
  50.  
  51.    cout<< "Please enter 'a' for ADDITION, 's' for SUBTRACTION, 'd' for DIVISION and 'm' for MULTIPLICATION: ";
  52.    cin>> opt;
  53.  
  54.    if(opt=='a' || 'A'){
  55.         AdditionEq();
  56.    }else if (opt=='s' || opt=='S'){
  57.         SubtractionEq();
  58.     }else if (opt=='d' || opt=='D'){
  59.         DivisionEq();
  60.     }else if (opt=='m' || opt=='M'){
  61.         MultiplicationEq();
  62.    }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement