#include <iostream>
#include <cstdlib>
usingnamespace std;
// Prototypes
int fibonacci(int);
int factorial(int);
void printMenu();
int getMenuChoice();
int getUserInput();
/**
* This is the main function, where all of the functions will be called and the program
* will be controlled.
*/
int main(){
//YOUR CODE GOES HERE!
//Here your program will call functions in order to
//a. Print the menu
//b. Get the user's selection
//c. Based on that selection, do the proper function
//d. repeat from step a, unless they chose the 'Quit' option
printMenu();
while(getMenuChoice != '3'){
(getMenuChoice=='1');
cout<<factorial(getUserInput())<<endl;
(getMenuChoice=='2');
cout<<fibonacci(getUserInput())<<endl;
printMenu();
return main;
}
/**
* This function will calculate the 'num' fibonacci number in a recursive fashion.
* Valid values for 'num' are num >= 0
* @param num is the fibonacci index desired
* @return The value of fibonacci(num)
*/
int fibonacci(int num){
//YOUR CODE GOES HERE
if(num=='1')return 1;
if(num=='0')return 0;
return num + sum(num-1)
}
/**
* This function will calculate the factorial of num in a recursive fashion
* Valid values for 'num' are num >= 0
* @param num is the number for which we are calculating the factorial
* @return will be num!
*/
int factorial(int num){
//YOUR CODE GOES HERE
if (num == '0' || num == '1')
return 1;
return num * factorial (num '-1')
}
/**
* This function will print out the entire menu for this program
*/
void printMenu(){
cout<<"*******************************"<<endl;
cout<<"Please choose an option:"<<endl;
cout<<"1. Factorial(n)"<<endl;
cout<<"2. Fibonacci(n)"<<endl;
cout<<"3. Quit"<<endl;
}
/**
* This function will get the user's menu choice.
* It will continue to ask the user for a value until a valid value (1-3) is given.
* @return a valid menu choice from the user.
*/
int getMenuChoice(){
int num;
cout<<"Input a number 1-3"<<endl;
cin>>num;
if(num >='1') && (num <='3')
return num;
cout<<"Invalid choice, please try again."<<endl;
return getMenuChoice();
}
/**
* This function will ask the user for 'n', which will eventually be used in the
* calculation of fibonacci or factorial.
* @return a value for 'n' to be used in calculating fibonacci or factorial.
*/
int getUserInput(){
int num;
cout<<"Input a number"<<endl;
cin>>num;
if (num >='0')
return num;
cout<<"Invalid choice, please try again."<<endl;
return getUserInput();
}
}
On line 26 and elsewhere, you are comparing a function name to a character. This tries to compare a pointer to the function to a char, which is where the error is coming from. I imagine you meant to call the function.
On line 87 you need parentheses around the entire if condition.
In the future, you should post the entire error messages, including the line numbers and such.