My program is to display a menu choice for the user, they will then pick one of the choices and the program will perform a calculation for the user. It contains four functions (menu, sum, power, and gcd) and it must contain reference parameters...i have most of the program, it wont compile, but shows no error messages either....I am new to this....heres the code:
#include<iostream>
using namespace std;
[B]void menu[/B](int& choice){
//menu prints out options to the user, and receives the user's choice
cout<<"1) Find the sum of 1 to n."<<endl;
cout<<"2) Find the power of x raised by y."<<endl;
cout<<"3) Find the greatest common divisor."<<endl;
cout<<"4) Quit."<<endl;
cin>>choice;
}
[B]void sum[/B](int num, int& result){
result = 0;
for (int a = 1; a<= num; a++)
result += a;
}
[B]void power[/B](int pow1, int pow2, int& result){
int i;
while ( i <= pow2 )
{
result *= pow1;
i++;
}
}
[B]void gcd[/B](int gcd1,int gcd2, int& result){
result = 0; //running total
for (int a = 1; a<= gcd2; a++)
result += a;
}
[B]int main[/B](){
int choice,num;
int num1,num2,input,outcome;
menu(choice);
while (choice != 4){
[B]switch[/B](choice){
[B]case 1[/B]: cout<<"Enter the number of sum to: ";
cin>>input;
[B]break[/B];
[B] case 2[/B]: cout<<"Enter the number to raise: ";
cin>>num1;
cout<<"Enter the power to raise to: ";
cin>>num2;
break;
[B]case 3[/B]: cout<<"Enter the first number: ";
cin>>num1;
cout<<"Enter the second number: ";
cin>>num2;
[B] break[/B];
}
[B]if[/B] (choice == 1) sum(input, outcome);
[B] else if [/B](choice == 2) power(num1,num2, outcome);
[B]else[/B] gcd(num1,num2, outcome);
cout<<"Result: "<<outcome<<endl;
[B]menu(choice)[/B];
}
[B] return 0[/B];
}