I need to change my previous program (below) to use functions such as:
int getIntSum(string s, int exitVal)
quizSum = getIntSum("Enter a quiz score", 0);
The purpose of this function is encapsulate the code to add up a series of user-entered values and return their sum. This function will display the string passed as the first argument along with the second value which is the special value to be entered by the user to signal that there are no more values to enter.
int getPromptedInt(string s, int min, int max)
maxTestPoints = getPromptedInt("Enter the maximum possible test points", 0, 200);
This function will ask for (via the first argument) and return an integer value between max and min.
I have no idea how to even start this ... any help would be great.
keep doing that until you get all your input.
to input it into a function you'd say
getIntSum(choice, 0) //you have to change it to an int 0 being the exit number so while (choice!=0)
Basically, to get it into a function you have to drop the void/int/double/string/ etc...
heres an example
void viewnumsum(int Number1, int Number2)
int main()
{
int num, num1;
cout<<"enter a number"<<endl;
cin>>num;
cout<<"enter another number"<<endl;
cin>>num1;
viewnumsum(num, num1);//drop the void and the int signs put your input in
}
void viewnumsum(int Number1, int Number2)//use the orignal function declared
{
cout<<Number1+Number2;
}
Hope this helps