出于某种原因,它不会打印我已经尝试过所有事情的退货声明,但我就是无法做到正确。
//calculator
#include <iostream>
using namespace std;
int input1;
int input2;
int add(int input1, int input2)
{
cout<<"Enter two numbers to add: ";
cin>> input1,input2;
return (input1 + input2);
}
int subtract(int input1, int input2)
{
cout<<"Enter first number to subtract: ";
cin>> input1;
cout<<"Enter second number to subtract: ";
cin>> input2;
return (input1 - input2);
}
int multiply(int input1, int input2)
{
cout<<"Enter two numbers to multiply: ";
cin>> input1, input2;
return (input1 * input2);
}
int main()
{
cout<<"what do you want to do: ";
int selection;
cout<<"1.add\n";
cout<<"2.subtract\n";
cout<<"3.multiply\n";
cin>>selection;
if (selection == 1) {
return add(input1, input2);
return input1 + input2;
}
else if (selection == 2) {
return subtract(input1, input2);
return input1 - input2;
}
else if (selection == 3) {
return multiply( input1, input2);
return input1 * input2;
}
else{
cout<<"Error choice not available";
}
cin.get();
system("pause");
}