1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
#include "stdafx.h"
# include <iostream>
int divide(int t, int g)
{
using namespace std;
return t / g;
}
int multiply(int e, int r)
{
using namespace std;
return e * r;
}
int subtract(int q, int w)
{
using namespace std;
return q - w;
}
int add(int x, int y)
{
using namespace std;
return x + y;
}
int main()
{
using namespace std;
int type; // variable for funtion chooser
// function chooser
cout << "do you want to add, subtract, multiply or divide" << endl;
cout << "press 1, 2, 3 or 4 respectivly" << endl;
cin >> type;
// for adding
if (type = 1){
int a, b;
cout << "type the first number" << endl;
cin >> a;
cout << "type the second number" << endl;
cin >> b;
cout << "the answer is " << add(a, b) << endl;
return 0;
}
// for subtracting
if (type = 2){
int q, w;
cout << "type the first number" << endl;
cin >> q;
cout << "type the second number" << endl;
cin >> w;
cout << "the answer is " << subtract(q, w) << endl;
return 0;
}
// for mulitplying
if (type = 3){
int e, r;
cout << "type the first number" << endl;
cin >> e;
cout << "type the second number" << endl;
cin >> r;
cout << "the answer is " << multiply(e, r) << endl;
return 0;
}
// for dividing
if (type = 4){
int t, g;
cout << "type the first number" << endl;
cin >> t;
cout << "type the second number" << endl;
cin >> g;
cout << "the answer is " << divide(t, g) << endl;
return 0;
}
}
|