Calculator Program

I've been assigned to make a program which can calculate all of the options stated below. I'm receiving an Error message saying "too few arguments to function 'void getOperands(int&, int&)'" and I'm wondering if anyone can help me out with this issue?

#include<iostream>
#include<stdio.h>
#include<cmath>
using namespace std;
void showMenu();
int getOperator(int selection);
void getOperands(int& num1, int&num2);
int addNumbers(int num1, int num2);
int divideNumbers(int num1, int num2);
int subtractNumbers(int num1, int num2);
int multiplyNumbers(int num1, int num2);
int remainderOfNumbers(int num1, int num2);
int exponentNumbers(int num1, int num2);
int factorialOfNumber(int num1, int n);
int log10Number(int num1);
void displayResults();
int main ()
{
displayResults();
/*system("pause");*/
return 0;
}
void showMenu()
{
cout<<"Enter---" <<endl;
cout<<" 1: + "<<endl;
cout<<" 2: / " <<endl;
cout<<" 3: - " <<endl;
cout<<" 4: * " <<endl;
cout<<" 5: % "<<endl;
cout<<" 6: ^ "<<endl;
cout<<" 7: ! "<<endl;
cout<<" 8: L "<<endl;
cout<<"Q: Quit" <<endl;
}
int getOption(int selection)
{
cin>>selection;
return selection;
}
void getNumbers(int& num1, int&num2)
{
cout<<"Enter two numbers: ";
cin>>num1 >>num2;
}
int addNumbers(int num1, int num2)
{
return num1+num2;
}
int divideNumbers(int num1, int num2)
{
return num1/num2;
}
int subtractNumbers(int num1, int num2)
{
return num1 - num2;
}
int multiplyNumbers(int num1, int num2)
{
return num1 * num2;
}
int remainderOfNumbers(int num1, int num2)
{
return num1 % num2;
}
int exponentNumbers(int num1, int num2)
{
return num1 ^ num2;
}
int factorialOfNumber(int num1)
{
unsigned int n;
unsigned long long factorial = 1;
for(int num1 = 1; num1 <=n; ++num1)
{
factorial *= num1;
}
}
int log10Number(int num1)
{
int x = num1;
double result;
return log10(x);
}
void displayResults()
{
int num1, num2, sum, choice;
do
{
showMenu();
cin>>choice;
cout<<endl;
switch (choice)
{
case 1:
getOperands(num1, num2);
sum=addNumbers(num1, num2);
cout<<num1 <<" + " <<num2 <<" = " <<sum <<"\n\n";
system("pause");
system("cls");
break;
case 2:
getOperands(num1, num2);
sum=divideNumbers(num1, num2);
cout<<num1 <<" / " <<num2 <<" = " <<sum <<"\n\n";
system("pause");
system("cls");
break;
case 3:
getOperands(num1, num2);
sum=subtractNumbers(num1, num2);
cout<<num1 <<" - " <<num2 <<" = " <<sum <<"\n\n";
system("pause");
system("cls");
break;
case 4:
getOperands(num1, num2);
sum=multiplyNumbers(num1, num2);
cout<<num1 <<" * " <<num2 <<" = " <<sum <<"\n\n";
system("pause");
system("cls");
break;
case 5:
getOperands(num1, num2);
sum=remainderOfNumbers(num1, num2);
cout<<num1 <<" % " <<num2 <<" = " <<sum <<"\n\n";
system("pause");
system("cls");
break;
case 6:
getOperands(num1, num2);
sum=exponentNumbers(num1, num2);
cout<<num1 <<" ^ " <<num2 <<" = " <<sum <<"\n\n";
system("pause");
system("cls");
break;
case 7:
getOperands(num1);
sum=factorialOfNumber(num1);
cout<<num1 <<" ! = " <<sum <<"\n\n";
system("pause");
system("cls");
break;
case 8:
getOperands(num1);
sum=log10Number(num1);
cout<<num1 <<" L = " <<sum <<"\n\n";
system("pause");
system("cls");
break;
default:
cout<<"Invalid input. Try again!" << "\n\n";
system("Pause");
}
} while (choice == 1 || choice == 2 || choice ==3 || choice == 4);
}
Last edited on
getOperands(num1);

This only passes one number when it was initialized with two parameters void getOperands(int& num1, int&num2);
Topic archived. No new replies allowed.