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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
#include <iostream>
using namespace std;
void add(int a, int b);
void sub(int a, int b);
void rem(int a, int b);
void mult(int a, int b);
void divd(int a, int b);
int main()
{
int num1, num2;
char sign;
bool repeat;
system(" TITLE calculator");
do{
repeat = false;
system("CLS");
cout << "Enter your two numbers." << endl;
cin >> num1;
cin >> num2;
cout <<"Now enter your sign." << endl;
cin >> sign;
if(sign == '+')
{
add(num1, num2);
}
if(sign == '-')
{
sub(num1, num2);
}
if (sign == '%')
{
rem(num1, num2);
}
if (sign == '*')
{
mult(num1, num2);
}
if (sign == '/')
{
divd(num1, num2);
}
cout << " would you like to repeat? 0. no 1, yes " << endl;
cin >> repeat;
}while(repeat == true);
return 0;
}
//...
void add(int a, int b)
{
int r;
r = a + b;
cout << a << "+" << b << "=" << r << endl;
system("pause");
}
//...
void sub(int a, int b)
{
int r;
r = a - b;
cout << a << "-" << b << "=" << r << endl;
system("pause");
}//...
void rem(int a, int b)
{
int r;
r = a % b;
cout << a << "%" << b << "=" << r << endl;
system("pause");
}//...
void mult(int a, int b)
{
int r;
r = a * b;
cout << a << "*" << b << "=" << r << endl;
system("pause");
}//...
void divd(int a, int b)
{
int r;
r = a / b;
cout << a << "/" << b << "=" << r << endl;
system("pause");
}//...
|