Too few arguments to functions!

Hi there below is my code for a program that determines the area under a curve by asking for user input for function, number of rectangles/triangles, and the start/end point.

I seem to be having issues with it compiling and would I would love it if someone more experienced could help me figure out the problem. I have included the compiling errors at the bottom of the post.


#include <iostream>
#include <cmath>
using namespace std;

//prototypes for all separate functions
int chooseFunc(int);
int chooseMethod(int);
int numRect(int, int);
int numTrap(int, int);
int startPoint(int);
int endPoint(int);
int rectAlg(int, int, double, double, int, double, double, int, int, int, int, int, int);
int func1(int, int, int);
int func2(int, int, int);
int func3(int, int, int);
int func4(int, int, int);
int func5(int, int, int);
int funcSum(int, double, double, int, int, int, int, int, int);
//calls all the functions
int main(){
   int choose, choose2, start, end, which, rect, trap, answer1, answer2, answer3, answer4, answer5, x, n;
   choose = chooseFunc(choose);
   choose2 = chooseMethod(choose2);
   rect = numRect(rect, choose2);
   trap = numTrap(trap, choose2);
   start = startPoint(start);
   end = endPoint(end);
   n = rectAlg(choose, start, end, rect, n);
   
   	return 0;
}


//asks user which function they want to use
int chooseFunc(int choose){
  cout<<"Choose a function (1,2,3,4, or 5): "<<endl;
  cin>>choose;
  return choose;
}
//asks the user which method they want to use
int chooseMethod(int choose2){
   cout<<"Would you like to calculate the area using the rectangle, trapezoid, or both? (1,2, or 3): "<<endl;
   cin>>choose2;
   return choose2;
}
//asks for the number of rectangles
int numRect(int rect, int choose2){
   if((choose2 == 1) || (choose2 == 3)){
      cout<<"How many rectangles would you like? "<<endl;
      cin>>rect;
      return rect;
   }
}
//asks for the number of trapezoids
int numTrap(int trap, int choose2){
   if((choose2 == 2) || (choose2 == 3))
      cout<<"How many trapezoids would you like? "<<endl;
      cin>>trap;
      return trap;
   }   
//asks the user for the starting point
int startPoint(int start){
   cout<<"Please select a starting point, a = "<<endl;
   cin>>start;
   return start;
}
//asks the user for the ending point
int endPoint(int end){
   cout<<"Please select an ending point, b = "<<endl;
   cin>>end;
   return end;
}

int func1(int x, int choose, int answer1){
   if(choose == 1){
   answer1 = (2*(pow(x,5)))+ pow(x,3)-10*x+2;}
   return answer1;
}
int func2(int answer2, int x, int choose){
   if(choose == 2){
   answer2 = (6*(pow(x,2)))-x+10;}
   return answer2;
}
int func3(int answer3, int x, int choose){
   if(choose == 3){
   answer3 = (5*x + 3);}
   return answer3;
}
int func4(int answer4, int x, int choose){
   if(choose == 4){
   answer4 = (2*(pow(x,3)))+120;}
   return answer4;
}
int func5(int answer5, int x, int choose){
   if(choose == 5){
   answer5 = (2*pow(x,2));}
   return answer5;
}
int funcSum(int choose, double sum , double n, int x, int answer1, int answer2, int answer3, int answer4, int answer5 ){

	sum = 0;
	cin >> choose;
	if (choose == 1)
	   sum += func1(n);
	else if (choose == 2)
	   sum += func2(n);
	else if (choose == 3)
	   sum += func3(n);
	else if (choose == 4)
	   sum += func4(n);
	else if (choose == 5)
	   sum += func5(n);
	
}
int rectAlg(int choose, int choose2, double start, double end, int rect, double n, double sum, int x, int answer1, int answer2, int answer3, int answer4, int answer5){
   if (choose2 == 1 || choose2 == 3){
   	double increment = (end - start)/rect;
   	double area = 0;
   	double total_area = 0;
   	for (int i = 1; i <= rect; i++)
   	{
   	area = i*increment * funcSum(n);
	total_area += area;
  	}
	cout << "The total area of all the rectangles for the function is:  " << total_area <<endl;}
}



assignment3.cpp: In function ‘int main()’:
assignment3.cpp:20: error: too few arguments to function ‘int rectAlg(int, int, double, double, int, double, double, int, int, int, int, int, int)’
assignment3.cpp:36: error: at this point in file
assignment3.cpp: In function ‘int funcSum(int, double, double, int, int, int, int, int, int)’:
assignment3.cpp:82: error: too few arguments to function ‘int func1(int, int, int)’
assignment3.cpp:112: error: at this point in file
assignment3.cpp:87: error: too few arguments to function ‘int func2(int, int, int)’
assignment3.cpp:114: error: at this point in file
assignment3.cpp:92: error: too few arguments to function ‘int func3(int, int, int)’
assignment3.cpp:116: error: at this point in file
assignment3.cpp:97: error: too few arguments to function ‘int func4(int, int, int)’
assignment3.cpp:118: error: at this point in file
assignment3.cpp:102: error: too few arguments to function ‘int func5(int, int, int)’
assignment3.cpp:120: error: at this point in file
assignment3.cpp: In function ‘int rectAlg(int, int, double, double, int, double, double, int, int, int, int, int, int)’:
assignment3.cpp:107: error: too few arguments to function ‘int funcSum(int, double, double, int, int, int, int, int, int)’
assignment3.cpp:130: error: at this point in file
All the calls to the function that the error message is pointing are wrong. For example, ‘int func5(int, int, int)’: you call it in funcSum as func5(n). You need to pass two more parameters. In main you do the same with rectAlg, calling it with only 5 parameters
In a few cases it looks like you're sending a parameter with an uninitialized variable. For example, this function:

choose = chooseFunc(choose);

choose was declared an int, but there's no value assigned to it until after this function is run. I think this function just needs a local variable to hold the value you want to return - you don't need to send it anything.

Topic archived. No new replies allowed.