First look at my development environment
System: Win7
Computer: Dell
Operating Environment: VS2015
Language: C + +
Simple Calculator Code
Arithmetic #include "stdafx.h" #include <iostream> #include <stdio.h> using namespace std;
void Add () {printf ("Enter the Addends to be evaluated (for example, a b)");
int adda=0, addb=0,addc=0;
Cin >> Adda;
Cin >> ADDB;
ADDC = ADDA+ADDB;
cout <<adda<< "plus" <<addb<< "equals" << addc << Endl;
void Substraction () {printf ("Enter the meiosis to calculate (for example, a b)");
int Suba = 0, Subb = 0, subc = 0;
Cin >> Suba;
Cin >> Subb;
SUBC = Suba-subb;
cout <<suba<< "minus" <<subb<< "equals" << subc << Endl;
void multiplication () {printf ("Enter the multiplier to be calculated (for example, a B) \ n");
int Mula = 0, mulb = 0, Mulc = 0;
Cin >> Mula;
Cin >> Mulb;
MULC = mula*mulb;
cout <<mula<< "Multiply" <<mulb<< "equals" << mulc << Endl;
void Division () {printf ("Enter the divisor to calculate (for example, a B) \ n");
int DSA = 0, DSB = 0, DSC = 0,dsd=0;
CIN >> DSA;
CIN >> DSB;
DSC = DSA/DSB;
DSD = DSA%DSB; cout <<dsa<< "except" <<d sb<< "equals" << DSC << "Yu" <<dsd<<endl;
} void operation ()//operational function {printf ("input data Select to do that operation \ n");
printf ("Input 0 Select exit, 1 Do addition, 2 do subtraction, 3 do multiplication, 4 do division (keep remainder) \ n");
int operatione = 0;
Cin >> Operatione;
cout << Endl;
try {if (Operatione = = 1) {//addition add ();
else if (Operatione = 2) {//subtraction substraction ();
else if (Operatione = 3) {//multiplication multiplication ();
else if (Operatione = 4) {//Departure division ();
else if (Operatione = = 0) {exit (0);
else {throw 1;
The catch (int i) {cout << "input error" << Endl;
} operation ();
int main () {printf ("Welcome to use this calculator");
Operation ();
return 0;
}
Code is simpler, I hope you can enjoy