Logic issue with program

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

//prototypes for all separate functions
int chooseFunc(int);
int chooseMethod(int);
int numRect(int);
int numTrap(int, int);
int startPoint(int);
int endPoint(int);
double rectAlg(int);
int func1(double);
int func2(double);
int func3(double);
int func4(double);
int func5(double);
double funcSum(double);
//calls all the functions
int main(){
   int choose, choose2, start, end, rect, trap; 
   double answer1, answer2, answer3, answer4, answer5, x, n, rectSum, functSum;
   choose = chooseFunc(choose);
   choose2 = chooseMethod(choose2);
   rect = numRect(rect);
   trap = numTrap(trap, choose2);
   start = startPoint(start);
   end = endPoint(end);
   functSum = funcSum(n);
   rectSum = rectAlg(choose2);
   
   	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 an integer starting point, a = "<<endl;
   cin>>start;
   return start;
}
//asks the user for the ending point
int endPoint(int end){
   cout<<"Please select an integer ending point, b = "<<endl;
   cin>>end;
   return end;
}

int func1(double x){
   int choose;
   int answer1;
   if(choose == 1){
   answer1 = (2*(pow(x,5)))+ pow(x,3)-10*x+2;}
   //return answer1;
}
int func2(double x){
   int choose;
   int answer2;
   if(choose == 2){
   answer2 = (6*(pow(x,2)))-x+10;}
   //return answer2;
}
int func3(double x){
   int choose;
   int answer3;
   if(choose == 3){
   answer3 = (5*x + 3);}
   //return answer3;
}
int func4(double x){
   int choose;
   int answer4;
   if(choose == 4){
   answer4 = (2*(pow(x,3)))+120;}
   //return answer4;
}
int func5(double x){
   int choose;
   int answer5;
   if(choose == 5){
   answer5 = (2*pow(x,2));}
}
double funcSum(double n){
   	int sum = 0;
	int choose;
	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);
	
}
double rectAlg(int choose2){
   int start;
   int end;
   int rect;
   double n;
   if (choose2 == 1 || choose2 == 3){
   	double increment = (endPoint(end) - startPoint(start))/numRect(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;}
}



It seems that my program will ask the user for the number of rectangles and trapezoids but will fail to compute the area under the curve from the user input. Therefore, I believe I have a logical error somewhere or I'm forgetting to call something somewhere.

Can someone help me find the point(s) where this is happening? Thanks!
Inside your rectAlg() function, you haven't initialised start, end or rect.

I'm surprised your compiler didn't warn you about that.
Topic archived. No new replies allowed.